Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How To Display Recent Posts By Category In WordPress

If you are a Wordpress developer there is a good chance that you might be looking for a way to display recent posts from a special Category either in the homepage or in a custom designed landing page. Well, we have provided a simple guide for you.

By following the tutorial given here, you will be able to display recent posts from a particular category in WordPress.

How To Display Recent Posts By Category In WordPress

1) To get started, log into your WordPress dashboard. Once done, click “Editor” under the “Appearance” tab.

2) Now, paste the following .php code either in “homepage.php” or “front-page.php” or “footer.php” or in any other place where you want to display recent posts from a specific category.

$catquery = new WP_Query( 'cat=2&posts_per_page=5' );
while($catquery->have_posts()) : $catquery->the_post();
?>


  • " rel="bookmark">





By adding this code, you can display recent posts from a particular category in WordPress. To change the category, change the Number next to “cat=” (the number is the category ID, which you can find from here: Posts -> Categories).

Also, you can change the number of recent posts display by changing the number next to “posts_per_page=” in the code given above.

If you are designing a magazine styled WordPress theme or if you are customizing your WordPress blog to give a magazine styled look, this tutorial will be of immense help to you.

If you encounter any issues while following this tutorial, do let me know via comments.

The post How To Display Recent Posts By Category In WordPress appeared first on Crack Aloud.



This post first appeared on Crack Aloud - Useful Tips, Tricks And Tutorials, please read the originial post: here

Share the post

How To Display Recent Posts By Category In WordPress

×

Subscribe to Crack Aloud - Useful Tips, Tricks And Tutorials

Get updates delivered right to your inbox!

Thank you for your subscription

×