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 Gearor.com.


Feel free to visit our Forum, subscribe our RRS Feed for news updates, and follow us on Twitter.

Related Posts

This entry was posted in WordPress Themes and tagged , , , , , , . Bookmark the permalink.

3 Responses to Getting Recent Posts in WordPress

  1. Pingback: Getting Recent Posts in WordPress | Gearor Tech Magazine - Tech, Gadgets, Websites, Business news

  2. Zack says:

    This may be the simplest way to get recent posts in WordPress.

  3. Pingback: WordPress: Getting Most Popular(Commented) Posts | Zack Live | Web2.0 WordPress Themes Plugins Kohana Web Design

Leave a Reply

Your email address will not be published. Required fields are marked *

*

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