I'm using the following function to remove the product title from the breadcrumbs displayed on the product page:
add_filter( 'woocommerce_get_breadcrumb', 'ed_change_breadcrumb' );
function ed_change_breadcrumb( $breadcrumb ) {
if(is_singular()){
array_pop($breadcrumb);
}
return $breadcrumb;
}
It works in that it does remove the title, but it also stops the last category/sub-category from being a hyperlink. How can I fix that?
For example:
Original breadcrumb
<a>
Home</a>
/<a>
Category</a>
/<a>
Sub Category</a>
/ Product TitleResult of the above function
<a>
Home</a>
/<a>
Category</a>
/ Sub Category
I need the Sub Category to still be clickable after removing the product title from the breadcrumbs.
Thanks