How to Add Related Posts in WordPress website/blog?

Posted on

In today’s information, we will know how the related posts is added below the post of WordPress. If you are a blogger then you must know about related posts. If I do not even know, then after reading this complete information, you can come to what is a related post and how a related post is added below any post.


Related Post What is it?

When someone gets angry on your blog website and he knows, then he also wants to read other information or articles related to that post, then for him to show more posts related to that article below the post. It is called Due to this, the visitors continue on the blog.

How to add related posts in WordPress?

You can put related posts in your blog or website in two ways.

  1. Without Plugin (Code and css)
  2. Plugins

Related posts add Without plugin-

It is very simple to add related post without plugin method. And there is also fast loading. For which you have to add the below code in your theme.

Copy the below code and add it to single.php.

Be sure to back up your theme before using any code. Because if the code doesn’t support your theme then the site may be here.

<?php $orig_post = $post;
global $post;
$categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;

'category__in' => $category_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=> 2, // Number of related posts that will be shown.

$my_query = new wp_query( $args );
if( $my_query->have_posts() ) {
echo '<div id="related_posts"><h3>Related Posts</h3><ul>';
while( $my_query->have_posts() ) {

<li><div class="relatedthumb"><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a></div>
<div class="relatedcontent">
<h3><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
<?php the_time('M j, Y') ?>
echo '</ul></div>';
$post = $orig_post;
wp_reset_query(); ?>

After adding this code save the file. And if you do not want to show the image (Thumbnail) in the related posts, then in the code

remove this code.

1.Related posts add by plugin-

If you are not able to add related posts through the code, then you can take the help of perseverance. Or if a code error is coming in the blog, then use the plugin.

1.Contextual Related posts plugin-

Contextual related post plugin is the best related post plugin, which you can fully customize.

Plugin Download

2.Yet Another related post plugin-


This is another related posts plugin which is one of the most popular related post plugin. Which has the highest downloading rank. In this plugin also many options have been given to customize related posts.

Download plugin

3.Inline Related post plugin-

This plugin is also great. If you want to show the related post online, then you can download and install this plugin.

Plugin Download

In today’s information, we have not told about adding related posts below WordPress post, you can easily set related posts in above mentioned plugins installed WordPress post.

Source link

Leave a Reply

Your email address will not be published.