Getting Recent Posts in WordPress

recent posts Getting Recent Posts in WordPress photo

Getting recent posts in you WordPress blog, is a old topic. WordPress now has a default widget to do this, but sometime we need to display recent posts outside of the widget area. It’s a simple task, you can use one line of codes to do it:

<?php wp_get_archives(’title_li=&type=postbypost&limit=10′); ?>

The function wp_get_archives() is used to display a date-based archives list. While setting ‘type’ to ‘postbypost’, it returns posts odered by post date, which means recent posts, that’s what we want. And then we need to set the limit of posts by ‘limit=10′. That’s it, we have 10 recent posts now, you can put this codes into wherever in your theme.

For detail of wp_get_archives(), you can visit the WordPress Codex here.

This article is also posted at ZackLive.com.


Discuss in our Forum

Related Posts

, , , , , ,

2 Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>