Add custom list item to Breadcrumb NavXT

A client wanted an additional list item in his Breadcrumb NavXT

Came up with the following action in theme functions.php:

Remove Breadcrumb NavXT list item

In a project I had to remove Products list item from Breadcrumb NavXT

/**
* Remove products breadcrumb
*
* @param object $breadcrumb_obj Breadcrumb object.
*/
function my_bcn_after_fill( $breadcrumb_obj ) {
if ( is_category() || is_tag() || is_tax() ) {
foreach ( $breadcrumb_obj->breadcrumbs as $key => $item ) {
if ( 'Products' === $item->get_title() ) {
unset( $breadcrumb_obj->breadcrumbs[ $key ] );
}
}
}
}
add_action( 'bcn_after_fill', 'my_bcn_after_fill' );

view raw
functions.php
hosted with ❤ by GitHub