Show Recent Posts From Category – Complete Guide

elegant themes affiliate

If you want to show recent posts from a specific category on your sidebar, then you will either have to use a plugin or a php function. Recent post widget which is present in wordpress by default and it’s a great way to show your latest articles to your visitors.

WordPress by default has support for recent post widget. But it has limited very customization options. You can only set the number of the list to show and a field to add a custom widget name.


1. WordPress Recent Posts From Category Plugin.

This plugin gives you the power to show recent posts from any category you desire. You have to just install it either from your administration panel or have to upload it through ftp. After successful uploading, you will find it under plugins page and from there you have to activate it.

After activating it move to your admin’s setting page and over their you will find wp recent post options panel.

This plugin uses a short code to dynamically load the article list from any selected category. You even get options to show post excerpt along with author name and date of publishing. Furthermore, you can specify the css selector which you can use to customize the widget.


As you can see in the above snapshot, I have selected “All” category option. You have to also do the same or have to choose the desired category from the drop-down list. Then you just need to click on the generated shortcode and you will be provided with a short code.

Now just copy the code and then paste it into a text widget inside any widget area. It can be a sidebar, footer, below post area or just any custom place where you wish to show you latest articles.

For those who want to modify the widget area with custom CSS, here I am providing some styles. First you will have to enter “widget_cust_entries” inside the container’s class field. Obviously, you can choose any custom class name but then you will have to edit the style accordingly. I think it will make your widget more attractive and will improve your page views.


.sidebar .widget_cust_entries li {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin: 0 -40px;
    padding: 15px 40px;
    border-bottom:1px solid rgba(0,0,0,0);
    font-family:"Noto Sans",sans-serif;

.sidebar .widget_cust_entries li a{

.sidebar .widget_cust_entries li a:hover{

.sidebar .widget_cust_entries .widget-title {
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    color: #fff;
    margin: -40px -40px 0;
    padding: 25px 0;
    text-align: center;

2. Recent Posts By Category Widget

This is another WordPress plugin but it doesn’t use any short code to load the posts. It works very similarly to the default widget but it just adds a drop down field. From this drop-down list, you can choose the category and then can set the number of posts to loads.


It’s a very basic add-on and so you don’t get any options to set custom container class.

3. Code Snippet

If you don’t like using plugins then you can use this custom code snippet. You have to just paste this code into your theme’s function.php file. Make sure that you don’t copy the starting tags or it will most probably break the proper functioning of your theme.


Also, make sure to replace the ‘nameit’ in line number 4 with your category name.

I wish you would have liked this post. If you need any more help then please let me know your problem in the comment area.

Leave a Comment