Related posts based on category video tutorial using Twenty Ten theme

WordPress tutorial how to show Related posts based on category.

Last year, I have made a video tutorial how to display related posts under your blog post based on tags without plugin, two versions.

WordPress related posts for Twenty ten, or other themes, and related posts for Thesis.

Both of those videos did not create related posts based on category, but based on tags.

I have record this tutorial actually a very long time ago, but I forgot to write a post for it.

I usually made several videos all at once, and then plan to write tutorials of them, but I forgot this one.

So I thought I have to post it today, since this question has been asked very long time ago.

Related posts based on category tutorial idea.

One of my visitor asked me if we can actually display related posts based on category on wordpress.

Because I am also a newbie, so i did some Google researches, and try it myself in my wordpress local blog.

I found the functions code in, and then applied with Twenty ten theme and it did work.

If you are using another wordpress theme, you can follow this tutorial as long as you have functions.php and single.php files.

To display where you want it to be displayed, you should check on what div you want it to show.

Related posts based on category screencast, and the steps.

Screenshot of the result from this tutorial

related post category

The result



1. First of all, you can visit this page, where the code is originally coming from.

I have to write a note, I have tried this with Thesis theme, it messed up my comment system.

Therefore, I suggest you to try first offline in a local wordpress installation, and once you are sure it works 100% with your theme, you can use it in your online blog.

2. We are using Twenty Ten theme in this tutorial, so paste this code or directly from wpengineer page, to your functions.php file. (see this screenshot, basically after “<?php” )

related posts based on category

Where to paste the code in functions php (right highlighted is the code)

3. After pasting it, we have to call this function in single.php file, where we want the theme to display these “related posts based on category” links.

I recommend you watch the video on this step, because instead of pasting echo fb_cat_related_posts();, we should paste echo fb_get_cat_related_posts(); as the correct one. (watch video for the explanation)

related post based on category

Missing "get" in the code

4. After saving the file, refresh your single post page, and you will see the list of the related posts based on category, watch the video for more clear step.

Share the knowledge
Share on Google+0Tweet about this on TwitterShare on Facebook0Pin on Pinterest0Share on Reddit0Email this to someonePrint this page