Summery Summery
Retrieve the archive title based on the queried object.
Syntax Syntax
Return Return
(string) Archive title.
Source Source
File: wp-includes/general-template.php
*/ $term_name = apply_filters( 'single_tag_title', $term->name ); } elseif ( is_tax() ) { /** * Filters the custom taxonomy archive page title. * * @since 3.1.0 * * @param string $term_name Term name for archive being displayed. */ $term_name = apply_filters( 'single_term_title', $term->name ); } else { return; } if ( empty( $term_name ) ) { return; } if ( $display ) { echo $prefix . $term_name; } else { return $prefix . $term_name; } } /** * Display or retrieve 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. * * @since 0.71 * * @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|void Title when retrieving. */ function single_month_title( $prefix = '', $display = true ) { global $wp_locale; $m = get_query_var( 'm' ); $year = get_query_var( 'year' ); $monthnum = get_query_var( 'monthnum' ); if ( ! empty( $monthnum ) && ! empty( $year ) ) { $my_year = $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 ) ) { return false; } $result = $prefix . $my_month . $prefix . $my_year;
Advertisement
Changelog Changelog
Version | Description |
---|---|
4.1.0 | Introduced. |