Codex

Template Tags/wp get archives

Description

This function displays a date-based archives list in the same way as get_archives(). The only difference is that parameter arguments are given to the function in query string format. This tag can be used anywhere within a template.

Usage

 <?php wp_get_archives('arguments'); ?> 

Examples

Default Usage

 <?php $defaults = array(
          
'type' => 'monthly',
          
'limit' => ,
          
'format' => 'html'
          
'before' => 
,
          
'after' => ,
          
'show_post_count' => false); ?>

By default, the usage shows:

Monthly archives links displayed Displays all archives (not limited in number) Displays archives in an <li> HTML list Nothing displayed before or after each link Does not display the count of the number of posts

Last Twelve Months

Displays archive list by month, displaying only the last twelve.

<?php wp_get_archives('type=monthly&limit=12'); ?>

Last Fifteen Days

Displays archive list by date, displaying only the last fifteen days.

<?php wp_get_archives('type=daily&limit=15'); ?>

Last Twenty Posts

Displays archive list of the last twenty most recent posts listed by post title.

<?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?>

Dropdown Box

Displays a dropdown box of Monthly archives, in select tags, with the post count displayed.
<select name=\"archive-dropdown\" onChange='document.location.href=this.options[this.selectedIndex].value;'> 
  <option value=\"\"><?php echo attribute_escape(__('Select Month')); ?></option> 
  <?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>

Parameters

type 
(string) The type of archive list to display. Defaults to WordPress settings. Valid values:
yearly monthly (Default) daily weekly postbypost
limit 
(integer) Number of archives to get. Default is no limit.
format 
(string) Format for the archive list. Valid values:
html - In HTML list (<li>) tags and before and after strings. This is the default. option - In select (<select>) or dropdown option (<option>) tags. link - Within link (<link>) tags. custom - Custom list using the before and after strings.
before 
(string) Text to place before the link when using the html or custom for format option. There is no default.
after 
(string) Text to place after the link when using the html or custom for format option. There is no default.
show_post_count 
(boolean) Display number of posts in an archive (1 - true) or do not (0 - false). For use with all type except 'postbypost'. Defaults to 0.

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, get_archives, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_dropdown_pages, wp_loginout, wp_register, query_posts, rss_enclosure

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser