You are here: Computer Video TutorialWordpress TutorialWordPress Related Posts Without Plugin
Due to regular updates on WP, if you look for Twenty Eleven theme modification or customization tutorial, first of all, first check this post. Thanks.

WordPress Related Posts Without Plugin

by Kimi on October 19, 2010

How to add or show related posts under your blog post without installing additional plugin.

I have posted how to add breadcrumbs without plugin and my best breadcrumbs plugin if you want a plugin, a few days ago, and today, i want to show you, how we can actually display related posts, which is usually you can find under your blog post.

This tutorial uses a shortcode that will display related posts based on “tags”, using TwentyTen theme. Of course you can apply it in your own theme, as long as it has functions.php.

blog seo
Example, Post A has “funny” as a tag, and the other post, Post B has the same “funny” as a tag.

When you click Post A, it will show after the post content, something like:

Related Posts:
1. Post B.

Related Posts section often helps to get better interlinking in your blog page, and can decrease bounce rate.

When your visitors read your post, they won’t soon go away, or close their browsers if they see many post titles options that may interest them to read.

Now if you want to use plugin for this, this Y.A.R.P.P (Yet Another Related Posts Plugin) used to be my best related post plugin.

So let’s create this related post under post without plugin (for demo, see my related post under this post):

Video:

blog seo

Step by step guide:

1. Dashboard → appearance → editor

2. Function theme which is functions.php file (always back up first)

3. Add this code. (download in .txt file)

Thanks to blue anvil.

4. Update File.
Now we want to call this function by displaying (echo) the shortcode after post content.

It means we must adding some codes in single.php.

5. Click single post file which is single.php, open it, and look for a line of code which said: (see image)

</div><!--#nav-below-->

Where to paste the code.

5. Right below this line, add this line:

<div id="relatedpost">
<h3>Related Posts:</h3>
<?php echo do_shortcode('[related_posts]');?>
</div><!--#relatedpost-->

6. Update file, and check your post. It should have related posts based on the same tags.

7. To stylize the css, you can modify anything you like, in this tutorial i use a simple one.

Add this line to your style.css and update the file.

#relatedpost h3{margin:25px 0 10px 0;}

That’s it, modify, stylize as you like to fit your theme color, etc.

Subscribe new tips via Email:

Was the post helpful? Share it to help others with:

{ 21 comments… read them below or add one }

Curious Little Person October 20, 2010 at 6:48 am

nice, i actually use the YAARP plugin to show the related posts on my new blog…

Will need to try this technique as I’ll have one plugin less with my thesis theme..

Thanks for this valuable info..

Cheers
Sandeep

Reply

Kimi October 20, 2010 at 7:44 am

Yes, Y.A.R.P.P was also my best fav plugin for related post.

If you want to work without plugin, it is also easy to implement in our blog with the tut above :-D

Thanks for coming by Sandeep.

Reply

Goutham October 20, 2010 at 8:12 am

Nice tutorial. :) Thanks for the share. :)

Reply

Kimi October 20, 2010 at 8:20 am

Hey Goutham,

Thanks for your nice words and commenting :)

Reply

Bryan October 20, 2010 at 10:58 am

hey kimi,

any ideas for adding this to thesis?

Reply

Kimi October 20, 2010 at 5:52 pm

Yeah Bryan, i have already put the post in schedule actually, it will be published in a few days.

Reply

Bryan October 22, 2010 at 10:12 am

ooh thx kimi. looking forward to it :)

Reply

Kavita October 21, 2010 at 7:42 am

I am using YARPP plugin. I wish had read this post much earlier. I always appreciate adding codes manually without using plugins. Thanks for the post anyway, Kimi

Reply

Kimi October 21, 2010 at 8:49 am

Same here Kavita, I also prefer adding stuff manually.

Thank you for visiting and leaving a comment, Cheers.

Reply

Vinay October 21, 2010 at 9:39 pm

YARPP is one of the best related posts plugin! Nice share Kim :)

Reply

Kimi October 22, 2010 at 1:50 pm

Same here Vinay, I used YARPP too.

Thanks for commenting.

Reply

Imran@TechiesBlog October 22, 2010 at 7:54 pm

Hi Kimi,

presently I am using YARPP plugin, I will doing some slight makeover of my blog and planing to use Similar Post plugin. But required you assistances to eliminate few plugins and maintain the functionality of the blog. Moreover I am also using thesis theme.

Thanks for Sharing
-Imran

Reply

Kimi October 22, 2010 at 10:51 pm

Hey Imran,

I already scheduled Thesis tutorial on this, stay updated, will be published in a few days.

Thanks!

Reply

Imran@TechiesBlog October 27, 2010 at 5:45 am

Thanks Kimi I will be waiting for it.

However I am not using Blogussion thesis skin it is my custom made skin, yeh u are right I have take few functionality of Blogussion.

It has become a hobby for his day where I see good I want to implement on my blog. It is more kind of experimentation and learn thesis.

Reply

Kimi October 27, 2010 at 7:21 am

I also like my Thesis clean.

Thanks for stopping by ;)

Aks October 24, 2010 at 1:09 pm

Awesome tutorial on adding related posts.

Reply

Kimi October 25, 2010 at 8:43 am

Thanks!

Reply

anuj@webtricks March 2, 2011 at 3:53 pm

is this trick work on thesis theme

Reply

Kimi March 3, 2011 at 9:10 am

Hi Anuj

Yes, but we need to modify a bit, here is a quick link on my Thesis tutorial: http://www.blog.web6.org/add-related-posts-in-thesis-theme-without-widget/

I hope this helps.

Kimi.

Reply

Toi March 9, 2011 at 3:45 am

Thanks I’m trying to reduce the number of plugins I use :)

Reply

Naziman April 11, 2012 at 10:46 pm

Thanks but actually i want related post by category if, category no other post, i want to make it by tag. but i don’t know how.

Reply

Leave a Comment

Please use a name instead of blog name or SEO stuff, otherwise it will be deleted right away.

About checkbox → See more my post:how to get rid of spam bots in wordpress post.

Thank you for visiting, you're always welcomed to be here again!

{ 1 trackback }

Previous post:

Next post: