Ready to get started?Download WordPress


Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get archives

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also wp-includes/deprecated.php. Use any of these functions instead.



Displays a list of links to date-based archives. This tag can be used anywhere within a template.

Replace With


 <?php get_archives$type$limit$format$before$after$show_post_count ); ?> 


(string) The type of archive list to display. Defaults to WordPress setting (defaults to 'monthly' in 1.5). Valid values:
  • 'monthly' (Default)
  • 'daily'
  • 'weekly'
  • 'postbypost'
(integer) Number of archives to get. Use '' for no limit.
(string) Format for the archive list. Valid values:
  • 'html' - In HTML list (<li>) tags. This is the default.
  • 'option' - In select or dropdown option (<option>) tags.
  • 'link' - Within link (<link>) tags.
  • 'custom' - Custom list.
(string) Text to place before the link when using 'custom' or 'html' for format option. Defaults to ''.
(string) Text to place after the link when using 'custom' or 'html' for format option. Defaults to ''.
(boolean) Display number of posts in an archive (TRUE) or do not (FALSE). For use when type is set to 'monthly'. Defaults to FALSE.


Default Usage

Displays archive links using defaults.

<?php get_archives(); ?>

By Month with Post Count

Displays all archives by month in an unordered list, with count of posts by month.

<?php get_archives('monthly', '', 'html', '', '', TRUE); ?>

Displays Last 10 Posts In A List

Displays a non-bulleted list of the last 10 posts separated by line breaks.

<?php get_archives('postbypost', '10', 'custom', '', '<br />'); ?>

Using Dropdown List

Displays monthly archives in a dropdown list; the use of javascript is required to have an archive selection open on the page.

<form id="archiveform" action="">
<select name="archive_chrono" onchange="window.location =
<option value=''>Select Month</option>
<?php get_archives('monthly','','option'); ?>

You also can use piece of code below, that works better than the example above. It shows the months list, including the number of posts/month.

 <select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
 <option value="">Select month</option>
 <?php get_archives('monthly',,'option',,,'TRUE'); ?>

List of Limited Number of Recent Posts

Displays a custom number of recent posts in an unordered list.

 <ul><?php get_archives('postbypost','10','custom','<li>','</li>'); ?></ul>

Change Log


List & Dropdown Functions

See also index of Function Reference and index of Template Tags.