: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Displays or retrieves title for a post type archive.
* This is optimized for archive.php and archive-{$post_type}.php template files
* for displaying the title of the post type.
* @param string $prefix Optional. What to display before the title.
* @param bool $display Optional. Whether to display or retrieve title. Default true.
* @return string|void Title when retrieving, null when displaying or failure.
function post_type_archive_title( $prefix = '', $display = true ) {
if ( ! is_post_type_archive() ) {
$post_type = get_query_var( 'post_type' );
if ( is_array( $post_type ) ) {
$post_type = reset( $post_type );
$post_type_obj = get_post_type_object( $post_type );
* Filters the post type archive title.
* @param string $post_type_name Post type 'name' label.
* @param string $post_type Post type.
$title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type );
* Displays or retrieves page title for category archive.
* Useful for category template files for displaying the category page title.
* The prefix does not automatically place a space between the prefix, so if
* there should be a space, the parameter value will need to have it at the end.
* @param string $prefix Optional. What to display before the title.
* @param bool $display Optional. Whether to display or retrieve title. Default true.
* @return string|void Title when retrieving.
function single_cat_title( $prefix = '', $display = true ) {
return single_term_title( $prefix, $display );
* Displays or retrieves page title for tag post archive.
* Useful for tag template files for displaying the tag page title. The prefix
* does not automatically place a space between the prefix, so if there should
* be a space, the parameter value will need to have it at the end.
* @param string $prefix Optional. What to display before the title.
* @param bool $display Optional. Whether to display or retrieve title. Default true.
* @return string|void Title when retrieving.
function single_tag_title( $prefix = '', $display = true ) {
return single_term_title( $prefix, $display );
* Displays or retrieves page title for taxonomy term archive.
* Useful for taxonomy term template files for displaying the taxonomy term page title.
* The prefix does not automatically place a space between the prefix, so if there should
* be a space, the parameter value will need to have it at the end.
* @param string $prefix Optional. What to display before the title.
* @param bool $display Optional. Whether to display or retrieve title. Default true.
* @return string|void Title when retrieving.
function single_term_title( $prefix = '', $display = true ) {
$term = get_queried_object();
* Filters the category archive page title.
* @param string $term_name Category name for archive being displayed.
$term_name = apply_filters( 'single_cat_title', $term->name );
* Filters the tag archive page title.
* @param string $term_name Tag name for archive being displayed.
$term_name = apply_filters( 'single_tag_title', $term->name );
* Filters the custom taxonomy archive page title.
* @param string $term_name Term name for archive being displayed.
$term_name = apply_filters( 'single_term_title', $term->name );
if ( empty( $term_name ) ) {
echo $prefix . $term_name;
return $prefix . $term_name;
* Displays or retrieves page title for post archive based on date.
* Useful for when the template only needs to display the month and year,
* if either are available. The prefix does not automatically place a space
* between the prefix, so if there should be a space, the parameter value
* will need to have it at the end.
* @global WP_Locale $wp_locale WordPress date and time locale object.
* @param string $prefix Optional. What to display before the title.
* @param bool $display Optional. Whether to display or retrieve title. Default true.
* @return string|false|void False if there's no valid title for the month. Title when retrieving.
function single_month_title( $prefix = '', $display = true ) {
$m = get_query_var( 'm' );
$year = get_query_var( 'year' );
$monthnum = get_query_var( 'monthnum' );
if ( ! empty( $monthnum ) && ! empty( $year ) ) {
$my_month = $wp_locale->get_month( $monthnum );
} elseif ( ! empty( $m ) ) {
$my_year = substr( $m, 0, 4 );
$my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );
if ( empty( $my_month ) ) {
$result = $prefix . $my_month . $prefix . $my_year;
* Displays the archive title based on the queried object.
* @see get_the_archive_title()
* @param string $before Optional. Content to prepend to the title. Default empty.
* @param string $after Optional. Content to append to the title. Default empty.
function the_archive_title( $before = '', $after = '' ) {
$title = get_the_archive_title();
if ( ! empty( $title ) ) {
echo $before . $title . $after;
* Retrieves the archive title based on the queried object.
* @since 5.5.0 The title part is wrapped in a `<span>` element.
* @return string Archive title.
function get_the_archive_title() {
$title = __( 'Archives' );
$title = single_cat_title( '', false );
$prefix = _x( 'Category:', 'category archive title prefix' );
$title = single_tag_title( '', false );
$prefix = _x( 'Tag:', 'tag archive title prefix' );
} elseif ( is_author() ) {
$title = get_the_author();
$prefix = _x( 'Author:', 'author archive title prefix' );
/* translators: See https://www.php.net/manual/datetime.format.php */
$title = get_the_date( _x( 'Y', 'yearly archives date format' ) );
$prefix = _x( 'Year:', 'date archive title prefix' );
} elseif ( is_month() ) {
/* translators: See https://www.php.net/manual/datetime.format.php */
$title = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
$prefix = _x( 'Month:', 'date archive title prefix' );
/* translators: See https://www.php.net/manual/datetime.format.php */
$title = get_the_date( _x( 'F j, Y', 'daily archives date format' ) );
$prefix = _x( 'Day:', 'date archive title prefix' );
} elseif ( is_tax( 'post_format' ) ) {
if ( is_tax( 'post_format', 'post-format-aside' ) ) {
$title = _x( 'Asides', 'post format archive title' );
} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
$title = _x( 'Galleries', 'post format archive title' );
} elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
$title = _x( 'Images', 'post format archive title' );
} elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
$title = _x( 'Videos', 'post format archive title' );
} elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
$title = _x( 'Quotes', 'post format archive title' );
} elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
$title = _x( 'Links', 'post format archive title' );
} elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
$title = _x( 'Statuses', 'post format archive title' );
} elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
$title = _x( 'Audio', 'post format archive title' );
} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
$title = _x( 'Chats', 'post format archive title' );
} elseif ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
$prefix = _x( 'Archives:', 'post type archive title prefix' );
$queried_object = get_queried_object();
$tax = get_taxonomy( $queried_object->taxonomy );
$title = single_term_title( '', false );
/* translators: %s: Taxonomy singular name. */
_x( '%s:', 'taxonomy term archive title prefix' ),
$tax->labels->singular_name
$original_title = $title;
* Filters the archive title prefix.
* @param string $prefix Archive title prefix.
$prefix = apply_filters( 'get_the_archive_title_prefix', $prefix );
/* translators: 1: Title prefix. 2: Title. */
_x( '%1$s %2$s', 'archive title' ),
'<span>' . $title . '</span>'
* Filters the archive title.
* @since 5.5.0 Added the `$prefix` and `$original_title` parameters.
* @param string $title Archive title to be displayed.
* @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 );
* Displays category, tag, term, or author description.
* @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();
echo $before . $description . $after;
* Retrieves the description for an author, post type, or term archive.
* @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.
function get_the_archive_description() {
$description = get_the_author_meta( 'description' );
} elseif ( is_post_type_archive() ) {
$description = get_the_post_type_description();
$description = term_description();
* Filters the archive description.
* @param string $description Archive description to be displayed.
return apply_filters( 'get_the_archive_description', $description );
* Retrieves the description for a post type archive.
* @return string The post type description.
function get_the_post_type_description() {
$post_type = get_query_var( 'post_type' );
if ( is_array( $post_type ) ) {
$post_type = reset( $post_type );
$post_type_obj = get_post_type_object( $post_type );
// Check if a description is set.
if ( isset( $post_type_obj->description ) ) {
$description = $post_type_obj->description;
* Filters the description for a post type archive.
* @param string $description The post type description.
* @param WP_Post_Type $post_type_obj The post type object.
return apply_filters( 'get_the_post_type_description', $description, $post_type_obj );
* Retrieves archive link content based on predefined or custom code.
* 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
* 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.
* @since 5.2.0 Added the `$selected` parameter.
* @param string $url URL to archive.
* @param string $text Archive text description.
* @param string $format Optional. Can be 'link', 'option', 'html', or custom. Default 'html'.
* @param string $before Optional. Content to prepend to the description. Default empty.
* @param string $after Optional. Content to append to the description. Default empty.
* @param bool $selected Optional. Set to true if the current page is the selected archive page.
* @return string HTML link content for archive.
function get_archives_link( $url, $text, $format = 'html', $before = '', $after = '', $selected = false ) {
$text = wptexturize( $text );
$aria_current = $selected ? ' aria-current="page"' : '';
if ( 'link' === $format ) {
$link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
} elseif ( 'option' === $format ) {
$selected_attr = $selected ? " selected='selected'" : '';
$link_html = "\t<option value='$url'$selected_attr>$before $text $after</option>\n";
} elseif ( 'html' === $format ) {
$link_html = "\t<li>$before<a href='$url'$aria_current>$text</a>$after</li>\n";
$link_html = "\t$before<a href='$url'$aria_current>$text</a>$after\n";
* Filters the archive link content.
* @since 4.5.0 Added the `$url`, `$text`, `$format`, `$before`, and `$after` parameters.
* @since 5.2.0 Added the `$selected` parameter.
* @param string $link_html The archive HTML link content.
* @param string $url URL to archive.
* @param string $text Archive text description.
* @param string $format Link format. Can be 'link', 'option', 'html', or custom.
* @param string $before Content to prepend to the description.
* @param string $after Content to append to the description.
* @param bool $selected True if the current page is the selected archive.
return apply_filters( 'get_archives_link', $link_html, $url, $text, $format, $before, $after, $selected );
* Displays archive links based on type and format.
* @since 4.4.0 The `$post_type` argument was added.
* @since 5.2.0 The `$year`, `$monthnum`, `$day`, and `$w` arguments were added.
* @see get_archives_link()
* @global wpdb $wpdb WordPress database abstraction object.
* @global WP_Locale $wp_locale WordPress date and time locale object.
* @param string|array $args {
* Default archive links arguments. Optional.
* @type string $type 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.
* @type string|int $limit Number of links to limit the query to. Default empty (no limit).
* @type string $format 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'.
* @type string $before Markup to prepend to the beginning of each link. Default empty.
* @type string $after Markup to append to the end of each link. Default empty.
* @type bool $show_post_count Whether to display the post count alongside the link. Default false.
* @type bool|int $echo Whether to echo or return the links list. Default 1|true to echo.
* @type string $order Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
* @type string $post_type Post type. Default 'post'.
* @type string $year Year. Default current year.
* @type string $monthnum Month number. Default current month number.
* @type string $day Day. Default current day.
* @type string $w Week. Default current week.
* @return void|string Void if 'echo' argument is true, archive links if 'echo' is false.
function wp_get_archives( $args = '' ) {
global $wpdb, $wp_locale;