wp_get_archives

SummerySummery

Display archive links based on type and format.

Syntax

wp_get_archives( string|array $args = '' )

ParametersParameters

$args

(string|array) (Optional) Default archive links arguments. Optional.

  • 'type'
    (string) Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly', 'yearly', 'postbypost', or 'alpha'. Both 'postbypost' and 'alpha' display the same archive link list as well as post titles instead of displaying dates. The difference between the two is that 'alpha' will order by post title and 'postbypost' will order by post date. Default 'monthly'.
  • 'limit'
    (string|int) Number of links to limit the query to. Default empty (no limit).
  • 'format'
    (string) Format each link should take using the $before and $after args. Accepts 'link' (<link> tag), 'option' (<option> tag), 'html' (<li> tag), or a custom format, which generates a link anchor with $before preceding and $after succeeding. Default 'html'.
  • 'before'
    (string) Markup to prepend to the beginning of each link.
  • 'after'
    (string) Markup to append to the end of each link.
  • 'show_post_count'
    (bool) Whether to display the post count alongside the link. Default false.
  • 'echo'
    (bool|int) Whether to echo or return the links list. Default 1|true to echo.
  • 'order'
    (string) Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'. Default 'DESC'.
  • 'post_type'
    (string) Post type. Default 'post'.
  • 'year'
    (string) Year. Default current year.
  • 'monthnum'
    (string) Month number. Default current month number.
  • 'day'
    (string) Day. Default current day.
  • 'w'
    (string) Week. Default current week.

Default value: ''

ReturnReturn

(void|string) Void if 'echo' argument is true, archive links if 'echo' is false.

SourceSource

File: wp-includes/general-template.php


			

ChangelogChangelog

Changelog
Version Description
5.2.0 The $year, $monthnum, $day, and $w arguments were added.
4.4.0 The $post_type argument was added.
1.2.0 Introduced.

See alsoSee also

Scroll to Top