Displaying “Related Posts” after every posts can be very crucial in increasing pageviews for your blog. Again it does not come by default with WordPress installation. But there are many plugins available for the purpose of displaying “Related Posts”.

Important one’s being -
- Yet Another Related Posts Plugin
- WordPress Related Posts
- WordPress Related Posts Plugin
- Related Posts by Category
- Contextual Related Posts
The list is quiet long. The most popular among these is Yet Another Related Posts Plugin aka “YARPP”. But here on my blog I use a Plugin “Simple Tagging” which can be used both for managing tags and displaying “Related Posts” based on tags. But if you don’t want to install another plugin on your server, then here is the code for you. Just place the following code anywhere you want to show “Related Posts” within loop. The code will display “Related Posts” based on the current post tag(s).
<?php //for use in the loop, list 5 post titles related to first tag on current post $tags = wp_get_post_tags($post->ID); if ($tags) { echo ‘Related Posts’; $first_tag = $tags[0]->term_id; $args=array( ‘tag__in’ => array($first_tag), ‘post__not_in’ => array($post->ID), ‘showposts’=>5, ‘caller_get_posts’=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></p> <?php endwhile; } } ?>
That’s working on my blog thanks a lot brother
You are welcome dude