How To Display Related Posts In The Same Category As Current Post



If you have been blogging for a while, you may face this problem with related posts widget. You have many categories, each of them has a decent number of posts. Currently, your related posts widget display posts from various category. What if you want the related posts widget to display only the posts that have the same categories as the current post? Sounds difficult to understand? Let’s have an example.

For example, you have two categories: Movies review and book reviews. Currently, if you visit any post of either category, you will see posts from both Movies review and Book reviews. What if you want to see only posts from Movies review when you visit a post in that category (and the same with books review)?

Well, I searched for a plugin that could do this job but couldn’t find one. Finally, I decided to create a plugin to accomplish this and surprisingly, it costed me only a few hours. I haven’t uploaded it to

However, you can download from here

How to use the plugin?

It is quite easy to use the plugin. Please go to Appearance->Widgets and drag a widget called Current Category Posts to your sidebar:

How To Display Related Posts In The Same Category As Current Post 7

Then, click on the widget (Current category posts) and you will see all the available options:

How To Display Related Posts In The Same Category As Current Post 8

As you can see, we have a few options here:

  1. Number of post shown: the maximum number of posts you want to show on the widget. You can set this number to any of your liking. I currently set 10 for this blog
  2. Show post thumbnail: Whether to show posts’ thumbnails or not. If you have thumbnails for most of your posts, this option should be checked
  3. Skip current post in list: Do you want to display the current post (the post that you are viewing) or hide it? If this option is checked, you will see the current post on the widget
  4. Display date: Do you want to display the date of the post (publish date)? Check if you want
  5. Order posts by: What kind of order you want for the post list? Currently, you can order the posts by name, date or a random order.
  6. Asc/Desc: Based on your selection on Order posts by, this option let you arrange the post by ascending or descending order

After setting up the widget, here is the result:

How To Display Related Posts In The Same Category As Current Post 9

Now, as you are reading this post, you can go to any categories and see the posts on sidebar change based on the category of the posts you are reading. For posts that have multiple categories, posts from all of their categories are included.

Some ideas for improvements

Currently, I set the image to have 70px * 70px. This is quite a rigid limitation. I’m thinking about letting the user choose the size of the image. Also, the styling is quite basic. It may be ideal to have a several themes for users to choose from. Finally, for posts that don’t have a featured image, users should have the option to set a default image. If you have ideas or suggestions, please let me know. I appreciate that!

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

2 thoughts on “How To Display Related Posts In The Same Category As Current Post

Leave a Reply

Your email address will not be published. Required fields are marked *