LoginSign Up

How to display related posts from same category?

প্রোগ্রামিং 1 year ago 23 Aug, 2019 at 6:50 pm 224
Linkedin Pint

The question has already been asked and the answer has been posted too,

 

Add this code inside your single.php after a loop wherever you want to show related post,

<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>
1 year ago

Abdullah sk
I,m article writer, part time job in kokilbd
Like - Dislike Votes 0 - Rating 0 of 10

Be the first to comment

Leave a Reply

Your email address will not be published.


*


Enter Captcha Here : *

Reload Image

     

আরও দেখুন

ফোরাম বিভাগ