Close Menu
My SiteMy Site
  • Home
  • Reviews
  • Computers
  • How Tos
  • Travel & Lifestyle
  • Phone ROMs
  • Contact
    • Advertise
    • About Us
Facebook X (Twitter) Instagram
My SiteMy Site
  • Home
  • Reviews
  • Computers
  • How Tos
  • Travel & Lifestyle
  • Phone ROMs
  • Contact
    • Advertise
    • About Us
My SiteMy Site
Home»Web Design Tips»Wordpress»How to Display Related Posts in WordPress Without Plugin
Wordpress

How to Display Related Posts in WordPress Without Plugin

Oscar FrankBy Oscar Frank2 Mins Read
Share
Facebook Twitter LinkedIn WhatsApp Pinterest Email

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“.

  • Read: Guide on How to Install A WordPress 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


    <?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),
    'showposts'=>5,
    'caller_get_posts'=>1
    );
    $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>
    <?php
    endwhile;
    }
    }
    ?>

  • 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..

Related post Wordpress Wordpress Plugins

Related Posts

WordPress Blog Hosting made easy with SeekaHost Blog Hosting Control Panel

December 4, 2020

How to Create a Website with Elementor Page Builder in WordPress

April 1, 2019

Top 3 Reasons Backing Up Your Files Offsite Is Extremely Important

February 27, 2018
View 4 Comments

4 Comments

  1. mr too good on February 7, 2013 6:11 am

    thanks for tis,but what about related post with thumbmaill? and also what numba of plugin is too much for one blog

    Reply
    • Oscar Frank on February 7, 2013 7:15 am

      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.

      Reply
  2. Lamide on September 4, 2014 10:53 pm

    Hello bro, can u give tell Me how to increase numbers of posts from the normal 10 to 20 on my carrington theme…. Thanks

    Reply
  3. Doronize on July 4, 2017 5:58 am

    Can i get a simple code that doesn’t have heading for my website http://www.doronize.com.ng i just need a code that will fit into my website perfectly

    Reply
Leave A Reply Cancel Reply

Recent Posts
  • 6 Sports Apps You Must Have On Your Phone
  • Valencia Travel Guide: All You Need to Know About This Spanish Gem
  • TikTok Faces Unexpected Ban in Senegal, Sparks Global Curiosity
  • The Apple GPT & Apple’s Chatbot Mysterious Debut
  • Triller Takes on TikTok: Filing for Public Listing
Get Exclusive Tech Insights!
My Site
Facebook X (Twitter) Instagram YouTube
© 2025 Oscarmini Co. Designed by illBytes.

Type above and press Enter to search. Press Esc to cancel.