Breaking News
Home / wordpress tutorials / How to display related post in wordpress

How to display related post in wordpress

Displaying related post in wordpress helps to keep visitors on your blog, thereby increasing pageview and this go a long way to get your account approve on time by google if you applied for adsense.

Why display related post in  wordpress?

Have you ever heard of bounce rate? bounce rate is the rate at which visitors bounce out of your blog or website(leave). Displaying related post in your  blog helps to reduce bounce rate because with related post showing on your post, users are showed post that might be of help to them.

There are two ways to display related post in wordpress

How to display related post in wordpress

displaying related post in wordpress with plugin: This is a simple method of displaying related post in wordpress, and it is  recommended for beginners.

To display related post all you have to do is install the Yet Another Related Post Plugin from the plugin directory. if you do not no how to install plugin click here.

There are numerous reason why we choose the Yet Another Related Post Plugin . This plugin uses a powerful algorithm to display related post based on tags, page, words and post. It also allow related post to be display in a blog RSS feed.

After activating the plugin, visit settings>>YARPP at the left corner of the wordpress admin dashboard

YARP

here you can choose how to display related post either by using tags,pages or thesame category.

One good thing about this plugin is that you can also use it to display related post in your blog sidebar. To use Yet Another Related Post Plugin to display related post in your blog sidebar, just visit the widget area and you will see a widget titled Related post . Just drag to the sidebar . for instruction on how to add widget to a sidebar click here.

related post in sidebar

 

displaying related post in wordpress without a plugin:  To display related post in your blog without a plugin, just copy the below code to where you want the related post to appear in your single.php file. note it is better to display related post after the content.

 

<?php

//for use in the loop, list 5 post titles related to first tag on current post5.    $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’=>114.        );

$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;

}

}

?>

Save the file, and then have a look at your blog: wow you just have 5 related   post displaying in your blog.

Thank you for reading this article please always use the share button and subscribe to our newsletter for more update.

find us on facebookfind us on twitter

 

Check Also

how to set featured image in wordpress

featured image hack in wordpress

One feature of wordpress  is the ability to assign a featured image  to each post. …

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.