wppaste
WordPress

block_core_breadcrumbs_get_archive_breadcrumbs(): array

Since
7.0.0
Source
wp-includes/blocks/breadcrumbs.php:361
Generates breadcrumb items for archive pages.

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

Reaches the database via get_term().

Scaling
Constant

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

Instructions
9–78

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

Plugin surface
1 hook

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

Called by
1

1 place 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_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.

WhenInstructionsCalls it makes
!is_date()9is_date(), get_queried_object()
!is_date() && !($queried_object instanceof) && !is_post_type_archive() && !is_author()21is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), is_author()
is_date()23is_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()25is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), is_author(), block_core_breadcrumbs_create_page_number_item()
is_date()27is_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–38is_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()30is_date(), get_queried_object(), block_core_breadcrumbs_is_paged(), is_post_type_archive(), is_author(), block_core_breadcrumbs_create_item()
is_date()30is_date(), get_query_var(), get_query_var(), get_query_var(), block_core_breadcrumbs_is_paged(), block_core_breadcrumbs_create_item()
is_date()32–42is_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()34is_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()34is_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–45is_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 instanceof37is_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)38is_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–49is_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 instanceof41is_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)42is_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)42is_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)46is_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)48is_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()51is_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)52is_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)52is_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()55is_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)56is_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–66is_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()59is_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–70is_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()63is_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–74is_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–78is_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

PHPCompiledExecutedBranchesNotes
8.6-dev1929–7815
8.51929–7815
8.41929–78159 fewer instructions than PHP 8.3
8.32019–8715
8.22019–8715
8.12019–87151 fewer instruction than PHP 7.4
7.42029–8715

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:

  1. apply_filters( post_type_archive_title )filterline 460 (+99 into the body)

    Filters the post type archive title.

Uses · 14

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

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.

  1. 7.0.4
  2. 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.