Are you wondering how to display related posts in WordPress? If you do, then you have come to the right place.
Related posts are important when it comes to decreasing the bounce rate on your site. So, if a user comes to your site from a search keyword, they might also want to see something related to that keyword.
It is your job to ensure that you give them that! This way, they will click on it, and improve time-on-site and also reduce bounce rate by doing so.
If you are running a site powered by Adsense, you will see improved earning as you give yourself more chances to earn!
We are going to use Yet Another Related Post Plugin article to showcase you how to display related posts in WordPress.
Let’s get started.
How to Display Related Posts in WordPress
There are two ways, you can display related posts in WordPress:
- Manual integration
- Using plugin
Let’s get started with the manual integration process.
Manual Integration
In the process, you need to make sure that know what you are doing. If you never touched code or do not know how WordPress works internally, it is better to go through the second route, i.e., using the plugin.
All you need to do is copy the code below in the single.php.
<?php
//In the for 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),
'posts_per_page'=>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(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php
endwhile;
}
wp_reset_query();
}
?>
Using Plugin
In this section, we will learn how to use plugins to display related posts. To do so, you can choose any related posts plugins out there. However, in this tutorial, we are going to use Yet Another Related Posts Plugin (YARPP).
You can also install the plugin through the WordPress dashboard.
Once installed, you need to activate it to make it work.
Now, you need to go to its settings to enable it.
To do so, go to settings, and then YARPP.
You will now be able to see the settings of the plugin as shown below.
As you can see, you get a plethora of things you can change.
The sections include the following:
- The Pool
- “Relatedness” options
- Display options for your website
- Display options for RSS
In The Pool you can change multiple options including the categories that you want to ignore when suggesting the related posts.
You can also disallow posts with Tag. Moreover, you can also choose to show password protected posts in related posts. This is an important setting as the visitor surely does not want to get redirected to a password-protected post.
However, you can always experiment and see the subscriber’s conversion rate and decide to deploy it if needed.
The last option is to choose the posts within a certain time period.
In the relatedness option, you will be able to customize the display related posts further.
Here, the first option is the Match threshold. It defines how many times the post will be shown in the related posts shown below an article. However, do not get confused by the number. The higher the number, the less the posts will be repeated. It is a good idea to set it to 2 for the best possible result.
You can also increase relatedness with the titles, bodies, categories, and tags. All of them let you put a heavyweight on each option to calculate the posts and its relatedness.
As a website owner, you can experiment with all the settings and choose the ones that fit your requirements better. The best approach for any site is to go with categories and tags consideration.
Lastly, you can also enable previous posts to show and all post types display.
The last section that you get in the YARPP is the display options for your website.
Here, you can change the maximum number of posts to display, their orientation, and so on. For example, you can choose to show five related posts in the Thumbnails option. You can do it here.
You can also decide on which sections of the website you want to enable related posts. By default, it is set to Posts only. You can also choose Media, Pages, and Blocks.
Moreover, you can also choose to configure the before/after related entries.
The last section is to display options for RSS which is similar to that of the above section but for RSS only.
With all the settings done, you need to save it simply. This will enable the related posts on your WordPress site.
If you are confused about what each section does and want to use the default settings, you can leave it as it is and enjoy what the plugin has to offer.
Can You Use Other Plugins to Display Related Posts?
Of couse, you can do it! Below are the recommended display related posts plugins that you can try out.
- Jetpack — Offers a feature to showcase related posts
- Related Post — Show related posts according to taxonomy and post.
- Inline Related Posts — Integrate related posts within the content
Conclusion
This leads us to the end of our tutorial on how to display related posts in WordPress.
We hope you are now confident in enabling the related posts on your site and can customize it according to your needs.
You may also want to see our step by step guide on how to create a membership site with WordPress.
0 Comments