WordPress How To

WordPress: Show Recent Posts on Homepage or in Sidebar

There used to be a plugin to grab and display most recent blog posts from WordPress database. Well, while you still can use it to get recent posts and them shown on homepage or in sidebar, you can now conveniently add a recent post widget from the WordPress control panel => Appearance => Widgets if your current theme is widget ready.

Use a Recent Posts Plugin

Lots of them!

Add Recent Posts Widget

Log in to your WordPress control panel and head to Appearance and on to Widgets, there’s this Recent Posts widget that you can instantly add to your theme. Make sure the theme you are using is enabled for widgets.

Rely on WordPress Template Tags Function

What you need is the WP template function wp_get_archives(). For instance, to show the latest 10 posts in sidebar, just insert the following line of PHP somewhere in sidebar.php:

<?php wp_get_archives('type=postbypost&limit=10'); ?>

Or in’s case, I added both the lists of 10 most recent posts as well as the 5 most recent comments in footer.php:

<ul class="recent-posts">
<?php wp_get_archives('type=postbypost&limit=10'); ?>
<ul class="recent-comments">
<?php if (function_exists('mdv_recent_comments')) {mdv_recent_comments(5);} ?>
WordPress How To

Update your theme to WordPress 2.7 with Comments Threading and Paging

Well dismiss me if I’m a little too late for this but just now I encountered this client who needs to update a wordpress theme, the comments section or comments.php to be precise, to accommodate some of the new features introduced in WordPress 2.7, comments threading and comments paging.

The easy way – for new themes

Just go download a distribution of wordpress 2.7, and unzip the package (install it, probably), click your way into wp-content/themes/default (the Default theme) and open comments.php with your favorite dev editor.

There’s the code you need to implement comments threading and comments paging in wordpress 2.7 in case you need to create new themes dedicated for version 2.7. Also, you have to explicitly enable threaded comments in wordpress administration panel: Settings –> Discussion –> Other comment settings –> Enable threaded (nested) comments. It’s disabled by default.

Update old themes to accommodate the threading feature

For old wordpress themes, if yours or your client’s blog has already updated to wordpress 2.7 (has to, because this change may make your theme backward-incompatible), to integrate the comments threading and paging, you need to follow these steps by Will to edit 2 files in your theme, header.php and comments.php.

This tiny tutorial is written and human friendly, you won’t be bitten. 😉