Stay up to date with our newest WordPress themes, WordPress plugins, WordPress tutorials, and other announcements.
You don’t need any custom queries or database calls just to get a list of recent posts. In fact, there’s a function built into WordPress that will do just that. It’s called, wp_get_archives(). You might recognize that as a way to display monthly archives, but with a few parameters, you can modify it to display a list of recently published WordPress posts. Here’s the code:
<?php wp_get_archives('title_li=&type=postbypost&limit=10'); ?>
What this will do is strip any WordPress added formatting and output a nice list of the 10 latest posts, each within it’s own <li> tag.
About Leland Fiegel
Leland Fiegel was the original founder of ThemeLab. He is a web developer who loves WordPress and blogging.