How to Display Recent Posts From A Specific Category In WordPress

Let’s got to display recent posts from a specific category in WordPress. It’s very easy and simple to display to display recent posts from a specific category in WordPress. In this article, we will show you how to easily display recent posts from a specific category in WordPress.

Here is the below code to add in your WordPress theme files where you want to display recent posts from a specific category.

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

This code will works for WordPress default post. As the default post type is “post”. If you would like to display the short content. You can also replace the the_content with the_excerpt to display post excerpts instead of full article.

We are hoping this article can give you the best way to effectively display recent posts from a specific category in WordPress.