How to Display Recent Posts From A Specific Category In WordPress

Do you want to display recent posts from a specific category on your WordPress site?

Filtering posts by category allow you to show more relevant recent posts which helps reduce bounce rate and increase pageviews.

In this article, we’ll show you different ways to display recent posts from a specific category in WordPress.

Why Filter Posts by Category in WordPress

Displaying recent posts allows users to discover new content as they browse through your website. This greatly helps increase your blog traffic and page views.

To make it even more useful, you may want to show recent posts relevant to the content users are currently viewing.

This simple step can encourage visitors to spend more time on your site which would lead to more email subscribers and customers.

Now, if you want to display all your posts from a specific category on a separate page, WordPress already takes care of this for you.

To find the category page, you simply need to go to Posts Β» Categories Β» View page and click on the β€˜View’ link below a category.

That being said, let’s take a look at how to easily display recent posts by category in different areas of your website. We’ll cover the following methods, you can jump to the one that interests you:

  • Adding Recent Posts by Category Using the Block Editor
  • Adding Recent Posts by Category in WordPress Sidebar
  • Adding Recent Posts by Category Using Code

Adding Recent Posts by Category Using Block Editor

By default, WordPress comes with the latest posts block in the block editor. It allows you to easily display recent posts inside a page or post, and you can even filter them by category.

First, you need to edit the post or page where you want to display the recent posts by category. On the post edit screen, click on the add new block button (+) and then look for the β€˜latest posts’ block.

You will see the block appear in the content area with a preview of your recent posts. Simply click to select the block, and you’ll see block settings in the right column.

At the top of the settings, you will see different options like showing featured image, post author, date, and content.

Now, you need to scroll down to the Sorting and filtering section under the block settings. From here, you need to enter the name of the category you want to show posts from.

You can even select multiple categories by separating category names with a comma.

You’ll notice the preview of your recent posts will change to only include posts from the categories you have chosen.

You can now save your post or page and preview it in a browser window. Here is how it looked on our test site showing recent posts from a specific category with featured images and post excerpts.

Adding Recent Posts by Category in WordPress Sidebar

This method is recommended for users who want to display recent posts from specific categories in their WordPress sidebar.

First, you need to install and activate the Recent Posts Widget With Thumbnails plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Appearance Β» Widgets page and add the β€˜Recent Posts with Thumbnails’ to your sidebar.

This widget comes with a ton of customization options that you can review and adjust to your own needs. You can start by providing a title for your widget and then scroll down to the β€˜Filter by category’ section.

From here, you can select the categories you want to show posts from. You can also select multiple categories by pressing the CTRL key (Command key on Mac) on your keyboard and clicking on categories that you want to select.

After that, don’t forget to click on the β€˜Save’ button to store your widget settings.

You can now visit your WordPress website to see your recent posts filtered by category in action.

Adding Recent Posts by Category Using Code

This method requires you to manually add code to your WordPress website. If you haven’t done this before, then see our guide on how to copy and paste code snippets in WordPress.

First, you need to copy and paste the following code in your WordPress theme’s functions.php file or a site-specific plugin.

Don’t forget to replace β€˜news’ with your own category slug (category nice name used in URLs). and save your changes.

Tip: You can also add multiple categories separated by a comma.

This code simply asks WordPress to display 5 recent posts from the category β€˜news’. It then displays those posts as a bullet list with thumbnail sized featured images.

Lastly, it creates a shortcode [categoryposts] that you add to a page, post, or sidebar widget. Next, we’ll show you how to use this shortcode.

Using Shortcode to Add Recent Posts by Category to Posts and Pages

Simply, edit the post or page where you want to display the recent posts by category. On the post edit screen, click on the add new block (+) button and then add Shortcode block to your content area.

Next, you need to add your shortcode [categoryposts] in the block settings.

You can now save your post or page and preview it to see your recent posts list in action. This is how it looked on our test site.

As you can see, the styling doesn’t look so neat. Don’t worry you can change that by adding some custom CSS code to your theme.

Simply, go to Appearance Β» Customize page to launch the theme customizer and then switch to the β€˜Additonal CSS’ tab in the left column.

You can add the following custom CSS code as a starting point.

Don’t forget to click on the β€˜Publish’ button to save your custom CSS code. You can now visit your post or page to view your recent posts styled a bit neatly now.

Adding Recent Posts by Category Shortcode to WordPress Sidebar

You can add the same shortcode to your WordPress sidebar or any widget-ready area.

Simply go to the Appearance Β» Widgets page and add a β€˜Text’ widget to your sidebar.

ou can now paste your shortcode [categoryposts] to the widget’s text area. Don’t forget to click on the save button to store your widget settings.

You can now visit your website to see your recent posts by category widget in action. Here is how it looked on our test website.

We hope this article helped you learn how to display recent posts from a specific category in WordPress. You may also want to see our guide on how to show personalized content to different users in WordPress, and our list of the best WordPress block plugins to further customize your site.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Leave a Reply

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

error: Content is protected !!

Pin It on Pinterest

Add address