block_core_breadcrumbs_get_archive_breadcrumbs(): array
- Since
- 7.0.0
- Source
wp-includes/blocks/breadcrumbs.php:361
Description
Handles taxonomy archives, post type archives, date archives, and author archives.
For hierarchical taxonomies, includes ancestor terms in the breadcrumb trail.
Compatibility
- WordPress
- since 7.0.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in 2 of the 5 tracked releases, added in 7.0.0, and compiles on PHP 7.4 through 8.6-dev.
Return value
array- Array of breadcrumb item data.
Performance profile
How much work a call to block_core_breadcrumbs_get_archive_breadcrumbs() 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
- 9–78
- Plugin surface
- 1 hook
- Called by
- 1
Reaches the database via get_term().
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 192.
Third-party callbacks on 'post_type_archive_title' run inside this call, and their cost is not bounded by anything here.
1 place 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_term()one call below block_core_breadcrumbs_get_archive_breadcrumbs()
Further down the call graph this can also reach option, 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 · 31 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost block_core_breadcrumbs_get_archive_breadcrumbs() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!is_date() | 9 | is_date(), get_queried_object() |
!is_date() && !($queried_object instanceof) && !is_post_type_archive() && !is_author() | 21 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), is_author() |
is_date() | 23 | is_date(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged() |
!is_date() && !($queried_object instanceof) && !is_post_type_archive() && !is_author() | 25 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), is_author(), block_core_breadcrumbs_create_page_number_item() |
is_date() | 27 | is_date(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), block_core_breadcrumbs_create_page_number_item() |
is_date() | 28–38 | is_date(), get_query_var(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged() |
!is_date() && !($queried_object instanceof) && !is_post_type_archive() && is_author() | 30 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), is_author(), block_core_breadcrumbs_create_item() |
is_date() | 30 | is_date(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), block_core_breadcrumbs_create_item() |
is_date() | 32–42 | is_date(), get_query_var(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), block_core_breadcrumbs_create_page_number_item() |
!is_date() && !($queried_object instanceof) && !is_post_type_archive() && is_author() | 34 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), is_author(), block_core_breadcrumbs_create_item(), block_core_breadcrumbs_create_page_number_item() |
is_date() | 34 | is_date(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), block_core_breadcrumbs_create_item(), block_core_breadcrumbs_create_page_number_item() |
is_date() | 35–45 | is_date(), get_query_var(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), block_core_breadcrumbs_create_item() |
19 further outcomes, up to 78 instructions
!is_date() && $queried_object instanceof | 37 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), block_core_breadcrumbs_get_term_ancestors_items(), array_merge(), block_core_breadcrumbs_create_item() |
!is_date() && !($queried_object instanceof) && is_post_type_archive() && !is_array($post_type) | 38 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), get_query_var(), get_post_type_object(), apply_filters() |
is_date() | 39–49 | is_date(), get_query_var(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), block_core_breadcrumbs_create_item(), block_core_breadcrumbs_create_page_number_item() |
!is_date() && $queried_object instanceof | 41 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), block_core_breadcrumbs_get_term_ancestors_items(), array_merge(), block_core_breadcrumbs_create_item(), block_core_breadcrumbs_create_page_number_item() |
!is_date() && !($queried_object instanceof) && is_post_type_archive() && !is_array($post_type) | 42 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), get_query_var(), get_post_type_object(), apply_filters(), block_core_breadcrumbs_create_page_number_item() |
!is_date() && !($queried_object instanceof) && is_post_type_archive() && is_array($post_type) | 42 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), get_query_var(), reset(), get_post_type_object(), apply_filters() |
!is_date() && !($queried_object instanceof) && is_post_type_archive() && is_array($post_type) | 46 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), get_query_var(), reset(), get_post_type_object(), apply_filters(), block_core_breadcrumbs_create_page_number_item() |
!is_date() && !($queried_object instanceof) && is_post_type_archive() && !is_array($post_type) | 48 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), get_query_var(), get_post_type_object(), apply_filters(), block_core_breadcrumbs_create_item() |
is_date() | 51 | is_date(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), get_year_link(), mktime(), date_i18n(), block_core_breadcrumbs_create_item() |
!is_date() && !($queried_object instanceof) && is_post_type_archive() && !is_array($post_type) | 52 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), get_query_var(), get_post_type_object(), apply_filters(), block_core_breadcrumbs_create_item(), block_core_breadcrumbs_create_page_number_item() |
!is_date() && !($queried_object instanceof) && is_post_type_archive() && is_array($post_type) | 52 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), get_query_var(), reset(), get_post_type_object(), apply_filters(), block_core_breadcrumbs_create_item() |
is_date() | 55 | is_date(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), get_year_link(), mktime(), date_i18n(), block_core_breadcrumbs_create_item(), block_core_breadcrumbs_create_page_number_item() |
!is_date() && !($queried_object instanceof) && is_post_type_archive() && is_array($post_type) | 56 | is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), get_query_var(), reset(), get_post_type_object(), apply_filters(), block_core_breadcrumbs_create_item(), block_core_breadcrumbs_create_page_number_item() |
is_date() | 56–66 | is_date(), get_query_var(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), get_year_link(), mktime(), date_i18n(), block_core_breadcrumbs_create_item() |
is_date() | 59 | is_date(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), get_year_link(), mktime(), date_i18n(), get_month_link(), block_core_breadcrumbs_create_item() |
is_date() | 60–70 | is_date(), get_query_var(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), get_year_link(), mktime(), date_i18n(), block_core_breadcrumbs_create_item(), block_core_breadcrumbs_create_page_number_item() |
is_date() | 63 | is_date(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), get_year_link(), mktime(), date_i18n(), get_month_link(), block_core_breadcrumbs_create_item(), block_core_breadcrumbs_create_page_number_item() |
is_date() | 64–74 | is_date(), get_query_var(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), get_year_link(), mktime(), date_i18n(), get_month_link(), block_core_breadcrumbs_create_item() |
is_date() | 68–78 | is_date(), get_query_var(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), get_year_link(), mktime(), date_i18n(), get_month_link(), block_core_breadcrumbs_create_item(), block_core_breadcrumbs_create_page_number_item() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 192 | 9–78 | 15 | |
| 8.5 | 192 | 9–78 | 15 | |
| 8.4 | 192 | 9–78 | 15 | 9 fewer instructions than PHP 8.3 |
| 8.3 | 201 | 9–87 | 15 | |
| 8.2 | 201 | 9–87 | 15 | |
| 8.1 | 201 | 9–87 | 15 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 202 | 9–87 | 15 |
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 · 1
One hook fires while block_core_breadcrumbs_get_archive_breadcrumbs() runs, in this order:
- apply_filters( post_type_archive_title )filterline 460 (+99 into the body)
Filters the post type archive title.
Uses · 14
- is_date()Determines whether the query is for an existing date archive.
- get_query_var()Retrieves the value of a query variable in the WP_Query class.
- block_core_breadcrumbs_is_paged()Checks if we're on a paginated view (page 2 or higher).
- get_year_link()Retrieves the permalink for the year archives.
- date_i18n()Retrieves the date in localized format, based on a sum of Unix timestamp and timezone offset in seconds.
- get_month_link()Retrieves the permalink for the month archives with year.
- block_core_breadcrumbs_create_item()Creates a breadcrumb item that's either a link or current page item.
- block_core_breadcrumbs_create_page_number_item()Creates a "Page X" breadcrumb item for paginated views.
- get_queried_object()Retrieves the currently queried object.
- block_core_breadcrumbs_get_term_ancestors_items()Generates breadcrumb items for hierarchical term ancestors.
- is_post_type_archive()Determines whether the query is for an existing post type archive page.
- get_post_type_object()Retrieves a post type object by name.
Show all 14
- apply_filters()Calls the callback functions that have been added to a filter hook.
- is_author()Determines whether the query is for an existing author archive page.
Used by · 1
- render_block_core_breadcrumbs()Renders the `core/breadcrumbs` block on the server.
Source code
function block_core_breadcrumbs_get_archive_breadcrumbs() { $breadcrumb_items = array(); // Date archive (check first since it doesn't have a queried object). if ( is_date() ) { $year = get_query_var( 'year' ); $month = get_query_var( 'monthnum' ); $day = get_query_var( 'day' ); // Fallback to 'm' query var for plain permalinks. // Plain permalinks use ?m=YYYYMMDD format instead of separate query vars. if ( ! $year ) { $m = get_query_var( 'm' ); if ( $m ) { $year = substr( $m, 0, 4 ); $month = substr( $m, 4, 2 ); $day = (int) substr( $m, 6, 2 ); } } $is_paged = block_core_breadcrumbs_is_paged(); if ( $year ) { if ( $month ) { // Year is linked if we have month. $breadcrumb_items[] = array( 'label' => $year, 'url' => get_year_link( $year ), ); if ( $day ) { // Month is linked if we have day. $breadcrumb_items[] = array( 'label' => date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) ), 'url' => get_month_link( $year, $month ), ); // Add day (current if not paginated, link if paginated). $breadcrumb_items[] = block_core_breadcrumbs_create_item( $day, $is_paged ); } else { // Add month (current if not paginated, link if paginated). $breadcrumb_items[] = block_core_breadcrumbs_create_item( date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) ), $is_paged ); } } else { // Add year (current if not paginated, link if paginated). $breadcrumb_items[] = block_core_breadcrumbs_create_item( $year, $is_paged ); } } // Add pagination breadcrumb if on a paged date archive. if ( $is_paged ) { $breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item(); } return $breadcrumb_items; } // For other archive types, we need a queried object. $queried_object = get_queried_object(); if ( ! $queried_object ) { return array(); } $is_paged = block_core_breadcrumbs_is_paged(); // Taxonomy archive (category, tag, custom taxonomy). if ( $queried_object instanceof WP_Term ) { $term = $queried_object; $taxonomy = $term->taxonomy; // Add hierarchical term ancestors if applicable.Changelog
Introduced in 7.0.0. Unchanged from 7.0.4 through 7.1.0.
Signature, return type and hooks compared across 2 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/blocks/breadcrumbs.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.