get_the_archive_title(): string
- Since
- 4.1.0, 5.5.0
- Source
wp-includes/general-template.php:1713
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
- Scaling
- Constant
- Instructions
- 33–104
- Plugin surface
- 2 hooks
- Called by
- 2
Reaches the database via get_post().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 268.
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.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly - querycontent query
get_post()one call below get_the_archive_title() - optionoption read or write
get_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.
| When | Instructions | Calls 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:
- apply_filters( get_the_archive_title_prefix )filterline 1783 (+70 into the body)
Filters the archive title prefix.
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 on which the post was written.
- 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
- is_tax()Determines whether the query is for an existing custom taxonomy archive page.
- is_post_type_archive()Determines whether the query is for an existing post type archive page.
- post_type_archive_title()Displays or retrieves title for a post type archive.
- get_queried_object()Retrieves the currently queried object.
- get_taxonomy()Retrieves the taxonomy object of $taxonomy.
- single_term_title()Displays or retrieves page title for taxonomy term archive.
- apply_filters()Calls the callback functions that have been added to a filter hook.
Used by · 2
- render_block_core_query_title()Renders the `core/query-title` block on the server.
- the_archive_title()Displays the archive title based on the queried object.
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.
Signature, return type and hooks compared across 5 parsed releases.
<span> element.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 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.