Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove post type from Breadcrumb NavXT breadcrumbs when viewing Tag archives.
<?php
/**
* Filter breadcrumbs to remove post archive when viewing Tag archives.
*/
add_action( 'bcn_after_fill', function( $bcn_breadcrumb_trail ){
// Bail early if not a tag archive.
if ( ! is_tag() ) {
return $bcn_breadcrumb_trail;
}
// Action needed. Loop over breadcrumb parts.
foreach ( $bcn_breadcrumb_trail->breadcrumbs as $breadcrumb_key => $breadcrumb ) {
// If breadcrumb is for target post archive.
if ( 465 === $breadcrumb->get_id() ) {
// Remove breadcrumb.
unset( $bcn_breadcrumb_trail->breadcrumbs[ $breadcrumb_key ] );
}
}
return $bcn_breadcrumb_trail;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.