WordPress.org

Ready to get started?Download WordPress

Codex

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

id:Tag Templat/wp get archives

Contents

Deskripsi

Fungsi ini menampilkan daftar arsip berdasarkan penanggalan. Tag ini juga bisa digunakan di templat.

Kegunaan

 <?php wp_get_archives$args ); ?> 

Penggunaan Standar

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

Secara standar, kegunaan fungsi ini adalah:

  • Menampiklkan autan arsip berdasarkan bulan
  • Menampilkan semua arsip tanpa batas
  • Menampilkan arsip dalam bentuk daftar HTML <li>
  • Tidak menampilkan apapun sebelum dan sesudah tautan
  • Tidak menampilkan jumlah total tulisan

Parameter

type 
(string) The type of archive list to display. Defaults to WordPress settings. Valid values:
  • yearly
  • monthly - Default
  • daily
  • weekly
  • postbypost (posts ordered by post date)
  • alpha (same as postbypost but posts are ordered by post title)
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 or do not. For use with all type except 'postbypost'.
  • 1 (True)
  • 0 (False) - Default
echo 
(boolean) Display the output or return it.
  • 1 (True) - Default
  • 0 (False)

Examples

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 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( 'type=monthly&format=option&show_post_count=1' ); ?>
</select>

To display the *ALL* posts alphabetically

Displays ALL posts alphabetically, especially if you want to have an archive that serves like a sitemap.

<?php wp_get_archives('type=alpha'); ?>

Change Log

Since: 1.2.0

Source File

wp_get_archives() is located in wp-includes/general-template.php.

Related

List & Dropdown Functions

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