Languages: English • Bahasa Indonesia • 日本語 (Add your language)
This function displays a date-based archives list. This tag can be used anywhere within a template.
<?php wp_get_archives( $args ); ?>
<?php $args = array(
'type' => 'monthly',
'limit' => '',
'format' => 'html',
'before' => '',
'after' => '',
'show_post_count' => false,
'echo' => 1,
'order' => 'DESC',
'post_type' => 'post'
);
wp_get_archives( $args ); ?>
By default, the usage shows:
<?php $my_archives=wp_get_archives(array( 'type'=>'alpha', 'show_post_count'=>true, 'limit'=>20, 'post_type'=>'post', 'format'=>'html' )); print_r($my_archives); ?>
Displays archive list by month, displaying only the last twelve months that have posts.
<?php wp_get_archives( array( 'type' => 'monthly', 'limit' => 12 ) ); ?>
Displays archive list by date, displaying only the last sixteen days.
<?php wp_get_archives( array( 'type' => 'daily', 'limit' => 16) ); ?>
Displays archive list of the last twenty most recent posts listed by post title.
<?php wp_get_archives( array( 'type' => 'postbypost', 'limit' => 20, 'format' => 'custom' ) ); ?>
Displays a drop-down 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 esc_attr( __( 'Select Month' ) ); ?></option> <?php wp_get_archives( array( 'type' => 'monthly', 'format' => 'option', 'show_post_count' => 1 ) ); ?> </select>
Displays ALL posts alphabetically, especially if you want to have an archive that serves like a sitemap.
<?php wp_get_archives('type=alpha'); ?>
wp_get_archives() is located in wp-includes/general-template.php.