Hallo gan, coba tambahkan kode ini di functions.php
function related_posts(){
echo '<div class="heading"><h4>Related Post</h4></div>';
echo '<div class="row">';
$orig_post = $post;
global $post;
$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'=> 6, // Number of related posts that will be shown.
'caller_get_posts'=>1
);
$my_query = new wp_query( $args );
if( $my_query->have_posts() ) :
while( $my_query->have_posts() ) :
$my_query->the_post();
echo '<div class="col-md-6" style="margin-top:8px;">';
if ( has_post_thumbnail() ) :
echo '<div class="media">';
echo '<div class="pull-left">';
printf(__('<a href="%1$s" title="%2$s">'), get_the_permalink(), the_title_attribute( 'echo=0' ));
echo the_post_thumbnail(array('100','100'), array( 'class' => 'media-object img-responsive' ));
echo '</a>';
echo '</div>';
echo '<div class="media-body">';
the_title('<h4 class="media-heading">','</h4>');
echo '<small><i class="fa fa-user"></i> '.get_the_author().' <i class="fa fa-calendar"></i> '.get_the_date("d/m/Y").'</small>';
echo get_excerpt(20);
echo '</div>';
echo '</div>';
endif;
echo '</div>';
endwhile;
endif;
}
$post = $orig_post;
wp_reset_query();
echo '</div>';
}
dan tambahkan file ini di single.php
<?php related_posts(); ?>
Keterangan :
Related post ini disesuaikan by category
jika kategorynya sama maka dibawahnya akan tampil post yg sama kategorinya.
terimakasih,
regard
[ Signature moderated ]