Display related post in WordPress without plugin

related post

There are a lot of ways to increase the number of people who visit your website.

But the easiest of all is to display related posts at the end of every post.

This will not only reduce your bounce rate as people might click through to read another post or two but will also increase the time people spend on your website. Both of which are a quality signal for Google. And of course, it will increase your page views.

There are two methods available to show related posts. The first method is via using any good plugin and the second method is to do it manually. Here we’ll show you how you can show related posts manually.

To add the functionality manually, you will have to add the following code to your wordpress theme wherever you want to show your related post. Usually, we show related posts at the end of the post.

<div class="related-posts-after-content">
  <h3>You Might Also Like</h3>
    $orig_post = $post;
    global $post;
    $tags = wp_get_post_tags($post->ID);
      $tag_ids = array();
      foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
        $args = array('tag__in'=>$tag_ids,'post__not_in'=>array($post->ID),
        $my_query = new wp_query($args);
          $my_query->the_post(); ?>
          <div class="related-thumb">
            <a rel="external" href="<?php the_permalink(); ?>">
              <?php the_post_thumbnail(array(150,100)); ?><br />
              <?php the_title(); ?>
        <?php }
     $post = $orig_post;


Read also: Facts you need to know about WordPress

Read also: Thrive Themes – WordPress themes and plugins

Simple preloader with Html and CSS
Display related post in WordPress without plugin