wppaste
WordPress

get_the_archive_title(): string

Since
4.1.0, 5.5.0
Source
wp-includes/general-template.php:1713
Retrieves the archive title based on the queried object.

Compatibility

WordPress
since 5.5.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Return value

string
Archive title.

Performance profile

How much work a call to get_the_archive_title() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reaches the database via get_post().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
33–104

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 268.

Plugin surface
2 hooks

Third-party callbacks on 'get_the_archive_title_prefix', 'get_the_archive_title' run inside this call, and their cost is not bounded by anything here.

Called by
2

2 places in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • querycontent queryget_post()one call below get_the_archive_title()
  • optionoption read or writeget_option()one call below get_the_archive_title()

Further down the call graph this can also reach cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 40 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost get_the_archive_title() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
is_category()33__(), is_category(), single_cat_title(), _x(), apply_filters(), apply_filters()
!is_category() && is_tag()36__(), is_category(), is_tag(), single_tag_title(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && is_author()37__(), is_category(), is_tag(), is_author(), get_the_author(), _x(), apply_filters(), apply_filters()
is_category()45__(), is_category(), single_cat_title(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && is_year()45__(), is_category(), is_tag(), is_author(), is_year(), _x(), get_the_date(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day() && !is_tax() && !is_post_type_archive()47__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_post_type_archive(), is_tax(), apply_filters(), apply_filters()
!is_category() && is_tag()48__(), is_category(), is_tag(), single_tag_title(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && is_month()48__(), is_category(), is_tag(), is_author(), is_year(), is_month(), _x(), get_the_date(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && is_author()49__(), is_category(), is_tag(), is_author(), get_the_author(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && is_day()51__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), _x(), get_the_date(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day() && !is_post_type_archive()51__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_post_type_archive(), is_tax(), get_queried_object(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day() && is_tax()52__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), _x(), apply_filters(), apply_filters()
28 further outcomes, up to 104 instructions
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day() && !is_tax() && is_post_type_archive()55__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_post_type_archive(), post_type_archive_title(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && is_year()57__(), is_category(), is_tag(), is_author(), is_year(), _x(), get_the_date(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()57__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day() && !is_tax() && !is_post_type_archive()59__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_post_type_archive(), is_tax(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && is_month()60__(), is_category(), is_tag(), is_author(), is_year(), is_month(), _x(), get_the_date(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()62__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && is_day()63__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), _x(), get_the_date(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day() && !is_post_type_archive()63__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_post_type_archive(), is_tax(), get_queried_object(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day() && is_tax()64__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day() && !is_tax() && is_post_type_archive()67__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_post_type_archive(), post_type_archive_title(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()67__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()69__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()72__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day() && !is_post_type_archive()73__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_post_type_archive(), is_tax(), get_queried_object(), get_taxonomy(), single_term_title(), _x(), sprintf(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()74__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()77__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()79__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()82__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()84__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day() && !is_post_type_archive()85__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_post_type_archive(), is_tax(), get_queried_object(), get_taxonomy(), single_term_title(), _x(), sprintf(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()86__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()87__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()89__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()92__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()94__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()98__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()99__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), _x(), sprintf(), apply_filters()
!is_category() && !is_tag() && !is_author() && !is_year() && !is_month() && !is_day()104__(), is_category(), is_tag(), is_author(), is_year(), is_month(), is_day(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), is_tax(), _x(), apply_filters(), _x(), sprintf(), apply_filters()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 268 instructions, 33–104 executed per call, 20 branches. The work does not change between versions.

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 2

2 hooks fire while get_the_archive_title() runs, in this order:

  1. apply_filters( get_the_archive_title_prefix )filterline 1783 (+70 into the body)

    Filters the archive title prefix.

  2. apply_filters( get_the_archive_title )filterline 1803 (+90 into the body)

    Filters the archive title.

Uses · 19

  • __()Retrieves the translation of $text.
  • is_category()Determines whether the query is for an existing category archive page.
  • single_cat_title()Displays or retrieves page title for category archive.
  • _x()Retrieves translated string with gettext context.
  • is_tag()Determines whether the query is for an existing tag archive page.
  • single_tag_title()Displays or retrieves page title for tag post archive.
  • is_author()Determines whether the query is for an existing author archive page.
  • get_the_author()Retrieves the author of the current post.
  • is_year()Determines whether the query is for an existing year archive.
  • get_the_date()Retrieves the date of the post.
  • is_month()Determines whether the query is for an existing month archive.
  • is_day()Determines whether the query is for an existing day archive.
Show all 19

Used by · 2

Source code

function get_the_archive_title() {	$title  = __( 'Archives' );	$prefix = ''; 	if ( is_category() ) {		$title  = single_cat_title( '', false );		$prefix = _x( 'Category:', 'category archive title prefix' );	} elseif ( is_tag() ) {		$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' );	} elseif ( is_year() ) {		/* 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' );	} elseif ( is_day() ) {		/* 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' );	} elseif ( is_tax() ) {		$queried_object = get_queried_object();		if ( $queried_object ) {			$tax    = get_taxonomy( $queried_object->taxonomy );			$title  = single_term_title( '', false );			$prefix = sprintf(				/* translators: %s: Taxonomy singular name. */				_x( '%s:', 'taxonomy term archive title prefix' ),				$tax->labels->singular_name			);		}	} 	$original_title = $title; 	/**	 * Filters the archive title prefix.	 *	 * @since 5.5.0	 *	 * @param string $prefix Archive title prefix.	 */	$prefix = apply_filters( 'get_the_archive_title_prefix', $prefix );	if ( $prefix ) {		$title = sprintf(			/* translators: 1: Title prefix. 2: Title. */			_x( '%1$s %2$s', 'archive title' ),			$prefix,			'<span>' . $title . '</span>'		);	}

Changelog

Introduced in 4.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.5.0
The title part is wrapped in a <span> element.from the docblock
4.1.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/general-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.