Search code examples
phpwordpresswoocommercebreadcrumbs

Remove "Shop" from Woocommerce breadcrumbs


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!


Solution

  • Update (2024): Get the correct index in the crumbs array (thanks to @Sebastian)

    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 array_values($crumbs);
    }
    

    Code goes in function.php file of your active child theme (or active theme). Tested and works.