How to Display Recent Posts From A Specific Category In WordPress?

Follow below code:-

Below code could be added where you want to display recent post in your theme.


<?php if ( have_posts() ) : ?>

<?php $catquery = new WP_Query( 'cat=18&posts_per_page=1' ); ?>

<?php while ($catquery->have_posts() ) : $catquery->the_post(); ?>

<?php the_content(); ?>

<?php endwhile; ?>

<?php endif; // end have_posts() check ?>

For more Reference click here.

About the Author

avatar