I don't have a main shop page, only product categories. The Woocommerce breadcrumbs always show a "Shop" trail in the breadcrumbs which I need to remove. In the Woo docs I can only fibd info on how to change tthe "home" slug or delimiter, or how to remove the breadcrumbs entirely. How do I simply remove the "Shop" trail though?
EDIT: I do not want to alter/change the name/link of the "shop" trail but completely remove it!
This worked for me, looks like woocommerce takes in consideration the index in the crumbs array.
add_filter('woocommerce_get_breadcrumb', 'remove_shop_crumb', 20, 2);
function remove_shop_crumb($crumbs, $breadcrumb)
{
$new_crumbs = array();
foreach ($crumbs as $key => $crumb) {
if ($crumb[0] !== __('Shop', 'Woocommerce')) {
$new_crumbs[] = $crumb;
}
}
return $new_crumbs;
}
I hope this helps someone Thanks
To remove completely "Shop" from Woocommerce breadcrumbs, use the following:
add_filter( 'woocommerce_get_breadcrumb', 'remove_shop_crumb', 20, 2 );
function remove_shop_crumb( $crumbs, $breadcrumb ){
foreach( $crumbs as $key => $crumb ){
if( $crumb[0] === __('Shop', 'Woocommerce') ) {
unset($crumbs[$key]);
}
}
return $crumbs;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With