Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

WordPress Post Archives Template Tag

The <?php wp_get_archives(); ?> template tag in WordPress displays the blog post archives in a number of ways, using the parameters and values below. Values that appear in bold are the default values set by WordPress. Here are just a few examples of what you can produce with this template tag:

  • Display the titles of the last 15 posts you’ve made to your blog.

  • Display the titles of the posts you’ve made in the past ten days.

  • Display a monthly list of archives.

    Parameter and Type Possible Values Example
    type (string): Determines the type of archive to display. monthly; daily; weekly; postbypost <?php wp_get_archives(‘type=postbypost’); ?>: Displays the titles of the most recent blog posts.
    format (string): Formats the display of the links in the archive list. html (surrounds links with <li> </li> tags); option (places archive list in drop-down list format); link (surrounds links with <link> </link> tags); custom (use your own HTML tags with before and after parameters) <?php wp_get_archives(‘format=html’); ?>: Displays the list of archive links in which each link is surrounded by the <li> </li> HTML tags.
    limit (integer): Limits the number of archives to display. If no value, all display <?php wp_get_archives(‘limit=10’); ?>: Displays the last ten archives in a list.
    before (string): Places text or formatting before the link in the archive list when using the custom parameter. No default <?php wp_get_archives(‘before=<strong>’); ?>: Inserts the <strong> HTML tag before each link in the archive link list.
    after (string): Inserts text or formatting after the link in the archive list when using the custom parameter. No default <?php wp_get_archives(‘after=</strong>’); ?>: Inserts the </strong> HTML tag after each link in the archive link list.
    show_post_count (Boolean): Displays the number of posts in the archive. You’d use this if you use the ‘type’ of monthly. true or 1; false or 0 <? wp_get_archives(‘show_post_count=1’); ?>: Displays the number of posts in each archive after each archive link.

Here are a couple examples of tags used to display blog post archives.

This tag displays a linked list of monthly archives (for example, January 2011, February 2011, and so on):

<?php wp_get_archives(‘type=monthly’); ?>

This tag displays a linked list of the 15 most recent blog posts:

<?php wp_get_archives(‘type=postbypost&limit=15’); ?>
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!