Site logo

Archived topic

Hiding breadcrumbs on Shop page, but not other shop archives

7 replies · Started by Alexandra on December 8, 2020

Viewing posts 1–8 of 8

Hi there,

try adding this PHP snippet:

add_action( 'init', 'woo_remove_wc_breadcrumbs' );
function woo_remove_wc_breadcrumbs() {
    if (is_shop()) {
        remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
    }
}

Hmm, it doesn't seem to work... I added it but the breadcrumb still shows up on the Shop page :(

Hmmm...

If you try this:

add_action( 'init', 'woo_remove_wc_breadcrumbs' );
function woo_remove_wc_breadcrumbs() {
        remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
}

Does it remove the breadcrumb ? it should remove it from everywhere - just want to check if its the hook or the IF condition thats the problem.

Hi, David!
Yes, this did remove the breadcrumb from everywhere.
So it seems like it's the IF condition that's the problem...

Aah ok, try this:

add_action( 'template_redirect', 'woo_remove_wc_breadcrumbs' );
function woo_remove_wc_breadcrumbs() {
    if (is_shop()) {
        remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
    }
}

That's awesome!
Thank you so much, David! :)
Worked perfectly!

Glad to be of help!

This archived topic is closed to new replies.