SAVE 25% when you purchase our Theme Bundle and Make Plus together. View bundle deal.

Recent posts in your WordPress sidebar

By Drew Strojny on May 31, 2008

While developing for WordPress you sometimes need to create a “non-widgetized” custom sidebar. You would also like to have a list of your most recent posts in that custom sidebar. Unfortunately, WordPress doesn’t have a “recent posts” template tag.

Here is a simple, easy to implement PHP file you can use to generate a list of recent posts in your custom “non-widgetized” sidebar.

Did you know that Surf Office, Postmatic, Yeah Dave, and over 700,000 small businesses run their websites with Make, our free WordPress page builder. Discover the Make page builder now.

Download this file: recent_posts.php. Now, upload it to the wp-content/themes/yourtheme directory, and insert the following code in your sidebar.php file where you want your recent posts list to appear:

<?php include (TEMPLATEPATH . "/recent_posts.php"); ?>

If you open up recent_posts.php in your favorite text editor you have the ability to change how many posts you want to display. You can also be more specific in what posts you want to display by passing different arguments to query_posts.

Enjoy this post? Read more like it in Tutorials.

One Response

  1. J.C

    Tnx, works great! Is it possible to do the same for showing ‘recent comments’? And how?

Comments are closed.