Related Posts с адаптивным дизайном

P
На сайте с 08.04.2013
Offline
100
829

Коллеги, подскажите хороший плагин для вывода Related Posts в виде картинок, чтобы смотрелся хорошо и самое главное - чтобы умел ресайзить каждый thumbnail. Мне нравится, как выглядит related posts от relap.io, но как-то стремно ставить его, ибо он от создателей Surfingbird.

A
На сайте с 20.08.2010
Offline
775
#1

Прямо беда. Я так понимаю, что помочь могут стили для адаптивной версии, если он вообще поддерживаются, но ничего не нашел.

P
На сайте с 08.04.2013
Offline
100
#2
awasome:
Прямо беда. Я так понимаю, что помочь могут стили для адаптивной версии, если он вообще поддерживаются, но ничего не нашел.

Да я не настолько крут в CSS, чтобы переписать его для плагина. Уверен, что косяки свои буду потом еще полгода разгребать. Хотелось все-таки, что-то готовое. Вот есть тема, Sahifa называется. Так там встроенный модуль Related есть. Он просто класс. Но не менять же тему сайта ради Related :(

mrdexters
На сайте с 07.10.2010
Offline
145
#3

Попробуйте так, реализация без плагина, в нужном месте в single.php вставьте


<?php
if ( true == get_theme_mod( 'related_posts', true )) {
$orig_post = $post;
global $post;

$categories = '';
$tags = '';

$related_count = get_theme_mod( 'related_posts_count', '3' );
//Related Posts By Categories
if (get_theme_mod( 'related_posts_by', 'categories' ) == 'categories') {
$categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
$args=array(
'category__in' => $category_ids,
'post__not_in' => array($post->ID),
'posts_per_page' => intval( $related_count ), // Number of related posts that will be shown.
'ignore_sticky_posts' =>1
);
}
}
//Related Posts By Tags
else {
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'posts_per_page' => intval( $related_count ), // Number of related posts to display.
'ignore_sticky_posts' =>1
);
}
}
if ($categories || $tags) {
$my_query = new wp_query( $args );
if( $my_query->have_posts() ) {
echo '<div class="relatedposts"><div class="widget-title-container"><div class="widget-title">' . __('Похожие записи','liveblog') . '</div></div><ul class="slides">';
while( $my_query->have_posts() ) {
$my_query->the_post();?>
<li>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<div class="relatedthumb">
<?php if ( has_post_thumbnail() ) { ?>
<?php the_post_thumbnail( 'featured' ); ?>
<?php } else { ?>
<img src="<?php echo get_template_directory_uri() . '/images/thumbnail-default.jpg'; ?>" style="height: 145px;"/>
<?php } ?>
</div>
<div class="related-content">
<div class="relatedtitle">
<?php the_title(); ?>
</div>
<div class="r-meta">
<?php if ( get_theme_mod( 'post_date', '1' ) ) { ?>
<time datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>"><i class="fa fa-clock-o"></i> <?php echo esc_html( get_the_date() ); ?></time>
<?php } ?>
</div>
</div><!--.related-content-->
</a>
</li>
<?php
}
echo '</ul></div>';
}
}
$post = $orig_post;
wp_reset_postdata();
}
?>

стили css


.relatedposts {
border-top:1px solid rgba(0, 0, 0, 0.11);
clear:both;
margin:0 0 30px;
padding:30px 0 20px;
position:relative;
}

.relatedposts ul {
margin: 0;
padding: 0;
}
.relatedposts ul li {
float:left;
list-style: none;
margin:0 1.4% 0 0;
position: relative;
width:32.4%;
}
.relatedposts ul li:nth-child(3n) { margin-right:0 }
.relatedposts ul li a img {
float: left;
height: auto;
width: 100%;
}
.relatedposts .title {
color: #fff;
font-size:15px;
line-height:22px;
margin:0 0 5px;
}
.relatedposts .relatedthumb {
display: block;
float: left;
height: 145px;
}
.relatedposts .related-content {
background: rgba(0, 0, 0, 0.4);
color: #fff;
clear:both;
line-height:20px;
min-height:40px;
padding:10px 10px 6px;
position: absolute;
bottom: 0;
left: 0;
right: 0;
text-align: center;
}
.r-meta {
display:block;
font-size:12px;
}

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий