in WordPress

Get Related Posts For Wordpress Post

Interlinks in your blog posts will allow your visitors to get related content to the current post. This will build up page views on your blog and build visitor engagement. But it can take up time to pick where to put links on your blog post and make sure you link correctly to related posts, so it will be better if this is done automatically by the Wordpress. Every post that you put up on your blog should have a set of tags which will explain what the blog post is about. Therefore if you can match these tags to other blog posts you will easily be able to find posts which are similar to the current post. Below is a PHP snippet of how to get the related posts by tags. Copy and paste this code and put it inside your single post loop and you will be able to get access to the related posts.

//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) {
  $tag_ids = array();
  foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;

  echo 'Related Posts';

    'tag__in' => $tag_ids,
    'post__not_in' => array($post->ID),

  $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="
      <?php the_title_attribute(); ?>">
      <?php the_title(); ?></a></p>

Get Related Posts As Premium Plugin

Or if you would prefer to have a Wordpress Plugin deal with this task of getting the related posts, there are a few plugins that can do this job. If you would like a premium plugin to give you some additional functionality then have a look at the plugin call Better Related Posts Widget. This plugin provides an advanced widget that allows you to display similar, or related, posts in any widgetized sidebar. Related posts are selected using tags, categories, or any custom taxonomy. When searching for related posts, the widget will choose posts that share between 1-3 like terms with the currently viewed post. Works with all custom post types! Features: - 12 Options to configure on a per-widget basis

  • Multiple instances of the same widget
  • Widget Title
  • Display related post titles
  • Option to display the post authors
  • Option to show post publication dates
  • Option to show post comment counts
  • Option to show post text excerpts
  • Option to control the length of the post excerpt
  • Option to show post thumbnails
  • Ability to control size of post thumbnails
  • Ability to set float of post thumbnails
  • Choose the number of related items to show
  • Select the taxonomy on which to relate posts
  • Widget shown only on single post pages

Get Your Copy

Subscribe To The Weekly Newsletter

Get weekly updates to your email