aioseo_breadcrumbs_template

Purpose

This filter can be used to change the HTML template for a specific crumb in the breadcrumbs trail.

Arguments (2)

  1. $templateItem (string) – The crumb template.
  2. $crumb (array) – The crumb information.

Example code snippet

The code snippet below is just an example of how this filter can be used. In the example below we’ll change the HTML if it’s the crumb of the ‘uncategorized’ category. This change will remove the <a> link to that category.

// Change the crumb html template for the uncategorized category removing it's link.
add_filter( 'aioseo_breadcrumbs_template', 'aioseo_breadcrumbs_template', 10, 2 );
function aioseo_breadcrumbs_template( $templateItem, $crumb ) {
	if ( is_a( $crumb['reference'], 'WP_Term' ) && 'uncategorized' === $crumb['reference']->slug ) {
		$templateItem['template'] = '<span class="aioseo-breadcrumb">
			#breadcrumb_label
		</span>';
	}

	return $templateItem;
}