Let’s say you want the 10 latest post of your blog to be displayed in the sidebar or footer, you can use “Recent Post” widgets or other wordpress functions such as wp_get_archives or wp_get_recent_posts to do so.
Recent Post Widget
The easiest way to get recent posts is by using the “Recent Posts” widgets. In order to do that, your theme have to support widgets, then you can go to WordPress Dashboard > Themes > Appearance > Widgets to place the “Recent Post” widget on a defined widgetized area (usually the sidebar or footer). Most wordpress themes which supports widgets will allow you to place widgets in the sidebar, but placing widgets in the footer is not a common feature in most wordpress themes. The default wordpress theme which comes with version 3 – TwentyTen – supports both.
What if Your Theme Doesn’t Support Widgets?
In this case, you will have to dive into wordpress functions. There are basically two functions which you can use.
wp_get_archives
Just insert this into your wordpress theme’s sidebar.php (or any other place you see suitable).
< ?php wp_get_archives('type=postbypost&limit=10); ?>
You can also customize the returned results by passing in other arguments. More reference here.
wp_get_recent_posts
Unlike wp_get_archives, wp_get_recent_posts returns an array and will require a little bit more code to get all the recent posts formatted/displayed.
Leave a Reply