In this post, I’m going to share an extremely useful widget for your WordPress projects. I’m sure that you’ve heard about the WordPress recent posts widget. It creates links to your recent posts in your sidebar so your visitors can reach the other blog posts you’ve written easily. It’s a great tool to create traffic within your blog.

recentpostswithexclude

But the widget we have in the WordPress core can be too simplistic for most of the well-maintained blogs and it needs modifications. For instance, you may want to show only the recent posts belonging to a specific category, or you may want to exclude some categories. Yes, there are many great plugins to achieve this functionality but a plugin for a simple task like this seems like an overkill. This code will help you to achieve those goals without installing any plugins. Just copy and paste the code below to your functions.php file.