Skip to content

Instantly share code, notes, and snippets.

@phlbnks
Created May 17, 2018 11:43
Show Gist options
  • Save phlbnks/130b6f9b297a9da72e8e806c5fde2491 to your computer and use it in GitHub Desktop.
Save phlbnks/130b6f9b297a9da72e8e806c5fde2491 to your computer and use it in GitHub Desktop.
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