How to Add and Display Related Posts in WordPress

How to Display Related Posts in WordPress (1)

One of the many fascinating ways to promote your articles and revive the old ones is by adding a Related Posts section to your site. The section not only helps you promote your articles, but your readers will also be satisfied and impressed with all the different content you’ve covered. It is considered as one of the crucial sections if you’re trying to run a successful and dynamic, all-rounder website. Today, we will be giving you two different methods to add and display related posts in WordPress. Let’s get started.

1. Display Related Posts by Using a Plugin

The first method is by using a WordPress plugin. You can either download a separate plugin that’s dedicated to displaying related posts or if you are already using Jetpack, you can simply enable the Related Posts module.

Using Jetpack

No need to say, Jetpack is one of the widely-used WordPress plugins out there. If you are using Jetpack, all you need to do is enable the Related Posts module. It will help you display an attractive related posts section underneath each article.

After installing and activating the Jetpack plugin, visit Jetpack > Settings from your WordPress dashboard. Then, select the Traffic tab and scroll down to Related Posts.

Now, activate the button next to Show related content after posts. This will enable the Related Posts section right after your posts.

You can further customize your Related Posts section on Live Customizer. You can enter a headline, choose to show thumbnail, date, and context. Also, you can either showcase your Related Posts in Grid or Lists layout.

Another way to easily display Related Posts using Jetpack is to add Related Posts Block available in Jetpack. This allows you to add the Related Posts section in a custom location within your post content. The customization options are identical in the RP block.

Using the YARPP plugin

First of all, you need to download and activate the Yet Another Related Posts Plugin (YARPP) from the WordPress plugin directory. After the activation, visit Settings > YARPP from your WordPress dashboard to customize the plugin your way.

Here you will be given all the customization power to configure the basic version of the plugin.

On the configuration page, we recommend you lower your match threshold number to 1 as it will solve the “no related posts” issue if the related posts are not showing up on your posts or pages.

After you’ve configured the plugin according to your requirements, click on the Save Changes. Now visit your site to see the plugin in action. You can also see the related posts tab on the screen editor after you’ve updated the post/page.

Here is how it shows on the Screen Editor:

And here is how it shows on the Live Site:

2. Display Related Posts Manually

Displaying related posts manually requires you to be familiar with coding. You need to paste the following code in single.php where you want your related posts to be displayed.

 <?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 ),
						'posts_per_page'       => 5,
						'ignore_sticky_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();
				}
				?>

I have pasted the code in the ‘after post’ section. Therefore, my Related Posts section displays after each post. Here’s a quick preview:

So, these were the two quick ways to add and display related posts in WordPress. You can choose whichever you’re comfortable with. If you have any questions, let us know in the comments section below.

Leave a Reply

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