Categories
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 kavoir.com’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>
<ul class="recent-comments">
<?php if (function_exists('mdv_recent_comments')) {mdv_recent_comments(5);} ?>
</ul>

By Yang Yang

Hello, I'm Yang. I build online businesses that please people. Want to join in and post some useful articles on Kavoir.com? Shoot me a message.

6 replies on “WordPress: Show Recent Posts on Homepage or in Sidebar”

Hello!
Very Interesting post! Thank you for such interesting resource!
PS: Sorry for my bad english, I’v just started to learn this language 😉
See you!
Your, Raiul Baztepo

I am interested in putting the most recent posts on my Homepage. The Homepage will not be part of WordPress though. Is this post only about putting the last posts on WordPress homepage?
Thanks

Comments are closed.