wp_get_archives() – Displays archive links based on type and format.

You appear to be a bot. Output may be restricted


Displays archive links based on type and format.


$void|string = wp_get_archives( $args );


( string|array ) optional – { Default archive links arguments. Optional.
( string ) optional – 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'.
( string|int ) optional – Number of links to limit the query to. Default empty (no limit).
( string ) optional – 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'.
( string ) optional – Markup to prepend to the beginning of each link. Default empty.
( string ) optional – Markup to append to the end of each link. Default empty.
( bool ) optional – Whether to display the post count alongside the link. Default false.
( bool|int ) optional – Whether to echo or return the links list. Default 1|true to echo.
( string ) optional – Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'. Default 'DESC'.
( string ) optional – Post type. Default 'post'.
( string ) optional – Year. Default current year.
( string ) optional – Month number. Default current month number.
( string ) optional – Day. Default current day.
( string ) optional – Week. Default current week. }


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


File name: wordpress/wp-includes/general-template.php

201 to 219 of 219
          if ( $result->post_title ) {
/** This filter is documented in wp-includes/post-template.php */
            $text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
          } else {
            $text = $result->ID;
          $selected = get_the_ID() === $result->ID;
          $output  .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );

  if ( $parsed_args['echo'] ) {
    echo $output;
  } else {
    return $output;

 View on GitHub View on Trac