Close

How to display related posts from same category?

নিচের দেওয়া কোডটি আপনি আপনার single.php
তে বসিয়ে দিন তারপর দেখতে পারবেন আপনার সাইটে একই ক্যাটাগরির পোষ্ট Related পোষ্ট আকারে দেখাবে।

<textarea><?php

$related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 5, 'post__not_in' => array($post->ID) ) );
if( $related ) foreach( $related as $post ) {
setup_postdata($post); ?>
 <ul> 
        <li>
        <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
            <?php the_content('Read the rest of this entry &raquo;'); ?>
        </li>
    </ul>   
<?php }
wp_reset_postdata(); ?>

<textarea>
svg737