Family Encyclopedia >> Electronics

How to Easily Display Recent Posts from a Specific Category in WordPress

Want to showcase the latest posts from a specific category on your WordPress site? The default Recent Posts widget pulls from all categories with no built-in filtering. As WordPress experts with years of hands-on experience helping thousands of users, we'll guide you through proven methods to display recent posts from one category effortlessly.

How to Easily Display Recent Posts from a Specific Category in WordPress

Access Posts via Dedicated Category Pages

WordPress automatically creates dedicated pages for each category, perfect for viewing recent posts from that group alone.

Add links to these pages by going to Appearance » Widgets and dragging the Categories widget to your sidebar. You can also include them in navigation menus under Appearance » Menus.

For sidebar displays of recent posts from a single category, no default widget exists—the standard one doesn't filter by category or tags.

Luckily, reliable solutions are available. Follow our step-by-step instructions below.

Video Walkthrough

Subscribe to WPBeginner for more expert video tutorials. If you prefer reading, continue below.

Method 1: Use the Extended Recent Posts Widget Plugin (Recommended)

This beginner-friendly approach is our top pick for most users, requiring no coding.

First, install and activate the Recent Posts Widget Extended plugin. See our detailed guide to installing WordPress plugins if needed.

Head to Appearance » Widgets, add the "Recent Posts Widget Extended" to your sidebar.

How to Easily Display Recent Posts from a Specific Category in WordPress

In the settings, select your desired category(ies) under "Limit to category." Customize further with thumbnails, dates, excerpts, and more.

Click Save, then visit your site to see category-specific recent posts in action.

How to Easily Display Recent Posts from a Specific Category in WordPress

Using Shortcodes for Posts and Pages

This plugin also supports shortcodes for embedding anywhere.

Edit your post or page, insert: [rpwe limit="5" excerpt="true" cat="72"]

This shows 5 recent posts from category ID 72 with excerpts. Swap "72" for your category ID—learn how to find category IDs.

Update the post/page to view results.

How to Easily Display Recent Posts from a Specific Category in WordPress

Method 2: Custom Code Snippet for Advanced Users

For full control without plugins, add this code to your theme files (use a child theme or Appearance » Theme Editor » functions.php safely—back up first. See our guide on editing code).

Place this where you want the list:

<?php
$catquery = new WP_Query( 'cat=12&posts_per_page=5' );
while($catquery->have_posts()) : $catquery->the_post();
?>
<ul>
<li><?php the_title(); ?></li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>

Replace "12" with your category ID. This lists titles.

For full content:

<?php
$catquery = new WP_Query( 'cat=12&posts_per_page=5' );
while($catquery->have_posts()) : $catquery->the_post();
?>
<ul>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php the_content(); ?>
</li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>

Swap the_content() with the_excerpt() for summaries.

We've relied on these techniques across countless sites. For more, check our top category plugins and hacks.

Liked this? Subscribe to our YouTube channel for tutorials, and follow on Twitter and Facebook.