get_archives_link

Advertisement

Summery Summery

Retrieve archive link content based on predefined or custom code.

Syntax Syntax

get_archives_link( string $url, string $text, string $format = 'html', string $before = '', string $after = '', bool $selected = false )

Description Description

The format can be one of four styles. The ‘link’ for head element, ‘option’ for use in the select element, ‘html’ for use in list (either ol or ul HTML elements). Custom content is also supported using the before and after parameters.

The ‘link’ format uses the <link> HTML element with the archives relationship. The before and after parameters are not used. The text parameter is used to describe the link.

The ‘option’ format uses the option HTML element for use in select element. The value is the url parameter and the before and after parameters are used between the text description.

The ‘html’ format, which is the default, uses the li HTML element for use in the list HTML elements. The before parameter is before the link and the after parameter is after the closing link.

The custom format uses the before parameter before the link (‘a’ HTML element) and the after parameter after the closing link tag. If the above three values for the format are not used, then custom format is assumed.

Parameters Parameters

$url

(Required) URL to archive.

$text

(Required) Archive text description.

$format

(Optional) default is 'html'. Can be 'link', 'option', 'html', or custom.

Default value: 'html'

$before

(Optional) Content to prepend to the description.

Default value: ''

$after

(Optional) Content to append to the description.

Default value: ''

$selected

(Optional) Set to true if the current page is the selected archive page.

Default value: false

Return Return

(string) HTML link content for archive.

Source Source

File: wp-includes/general-template.php

	 * @param string $original_title Archive title without prefix.
	 * @param string $prefix         Archive title prefix.
	 */
	return apply_filters( 'get_the_archive_title', $title, $original_title, $prefix );
}

/**
 * Display category, tag, term, or author description.
 *
 * @since 4.1.0
 *
 * @see get_the_archive_description()
 *
 * @param string $before Optional. Content to prepend to the description. Default empty.
 * @param string $after  Optional. Content to append to the description. Default empty.
 */
function the_archive_description( $before = '', $after = '' ) {
	$description = get_the_archive_description();
	if ( $description ) {
		echo $before . $description . $after;
	}
}

/**
 * Retrieves the description for an author, post type, or term archive.
 *
 * @since 4.1.0
 * @since 4.7.0 Added support for author archives.
 * @since 4.9.0 Added support for post type archives.
 *
 * @see term_description()
 *
 * @return string Archive description.

Advertisement

Changelog Changelog

Changelog
Version Description
5.2.0 Added the $selected parameter.
1.0.0 Introduced.

Advertisement

Leave a Reply