As I always would say, WordPress has an edge over other blogging platforms because of the various plugins which are made readily available by countless number of developers and as such making it easy for bloggers to achieve lots of things on their blog. You might be wondering now, why then the title about “How to Add Related Post to WordPress Theme Without a Plugin“.

Adding lots of plugins to your wordpress blog can clog you blog, thereby slowing down your site, some plugins might not work alongside each other, while some others which have been abandoned by their developers can have vulnerability risks,  you can now imagine why I would be teaching you how to show related posts in wordpress without the use of a plugin. Enough of the stories, let me go straight to the point.

how to display related post without plugin in wordpress

Adding Related Post to WordPress Blog Without the Use of Plugin

  • Login to your WordPress Dashboard. Go to Appearance > Editor.
  • Now click on single.php whichh is located on the right sidebar of your dashboard, a new page would be displayed for you to Edit.
  • Search for

    <?php the_content(); ?>

    Directly below it, paste the below code

    //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;
    'tag__in' => array($first_tag),
    '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="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>

  • Now Click on Update File

Note: To this related post tutorial works with your Tags, also the default number of related post it displays is 5. To change the value, change 5 to whatever you want in the code.

Did this help you, Why not share.. Sharing is Caring..


    • You are Welcome. There is no specific number of plugins which are too many for a wordpress blog, it depends on the CPU usage of the Plugin. For instance one Related Post plugins can make use of more CPU usage than 2 google xml sitemaps plugins.
      I hope you understand this.


Please enter your comment!
Please enter your name here