wp-includes/general-template.php:2002Displays archive links based on type and format.
$argsstring|arrayoptional''$typestringdefault: 'monthly'
$limitstring|intdefault: empty (no limit)
$formatstringdefault: 'html'
$beforestringdefault: empty
$afterstringdefault: empty
$show_post_countbooldefault: false
$echobool|intdefault: 1|true to echo
$orderstringdefault: 'DESC'
$post_typestringdefault: 'post'
$yearstringdefault: current year
$monthnumstringdefault: current month number
$daystringdefault: current day
$wstringdefault: current week
void|string4 hooks fire while wp_get_archives() runs, in this order:
Filters the arguments for displaying archive links.
Filters the SQL WHERE clause for retrieving archives.
Filters the SQL JOIN clause for retrieving archives.
function wp_get_archives( $args = '' ) { global $wpdb, $wp_locale; $defaults = array( 'type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false, 'echo' => 1, 'order' => 'DESC', 'post_type' => 'post', 'year' => get_query_var( 'year' ), 'monthnum' => get_query_var( 'monthnum' ), 'day' => get_query_var( 'day' ), 'w' => get_query_var( 'w' ), ); /** * Filters the arguments for displaying archive links. * * @since 7.0.0 * * @see wp_get_archives() * * @param array<string, string|int|bool> $args Arguments. */ $args = apply_filters( 'wp_get_archives_args', $args ); $parsed_args = wp_parse_args( $args, $defaults ); $post_type_object = get_post_type_object( $parsed_args['post_type'] ); if ( ! is_post_type_viewable( $post_type_object ) ) { return; } $parsed_args['post_type'] = $post_type_object->name; if ( '' === $parsed_args['type'] ) { $parsed_args['type'] = 'monthly'; } if ( ! empty( $parsed_args['limit'] ) ) { $parsed_args['limit'] = absint( $parsed_args['limit'] ); $parsed_args['limit'] = ' LIMIT ' . $parsed_args['limit']; } $order = strtoupper( $parsed_args['order'] ); if ( 'ASC' !== $order ) { $order = 'DESC'; } // This is what will separate dates on weekly archive links. $archive_week_separator = '–'; $sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $parsed_args['post_type'] ); /** * Filters the SQL WHERE clause for retrieving archives. * * @since 2.2.0 * * @param string $sql_where Portion of SQL query containing the WHERE clause. * @param array $parsed_args An array of default arguments. */ $where = apply_filters( 'getarchives_where', $sql_where, $parsed_args ); /** * Filters the SQL JOIN clause for retrieving archives. * * @since 2.2.0 * * @param string $sql_join Portion of SQL query containing JOIN clause. * @param array $parsed_args An array of default arguments. */ $join = apply_filters( 'getarchives_join', '', $parsed_args ); $output = '';Introduced in 1.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/general-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.