My title

Page 177

177

Building a Basic Theme: Creatif Blog

Using WP_Query is a very flexible method of getting recent Posts. An alternative method is to use the Template Tag wp_get_ archives(), a tag usually used to get monthly archives (see below). By passing some alternative parameters we can grab the most recent post titles instead. Here’s the code: <li id="recent_posts" class="widget"> <ul><?php wp_get_archives('type=postbypost&limit=7'); ?></ul> </li>

Monthly Archives Date based archives show the reader a list of dates and allow the reader to click through and see all Posts from those dates. You can choose whether to display monthly, weekly, daily or yearly archives. Like most blogs, we’re going to use monthly. The Template Tag used here will again be wp_get_archives(). Two parameters need to be set – ‘type’ and ‘limit’. We want to show by the month and a maximum of seven: <li id="archives" class="widget"><h3>Archives</h3> <ul><?php wp_get_archives('type=monthly&limit=7'); ?></ul> </li>

This will simply display an unordered list of the seven more recent months – displayed as ‘December 2008’. Later we’ll look further in depth at archives, we’re only scratching the surface with this little beauty! Codex Page for wp_get_archives: http://codex.wordpress.org/ Template_Tags/wp_get_archives


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.