• Resolved Alberto Balsalm

    (@francoisduroy)


    Hello guys,

    I have been searching for a long time to find the way to remove the breadcrumb (storefront theme).

    This code works well :

    
    function wc_remove_storefront_breadcrumbs() {
      remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10 );
    }
    add_action( 'init', 'wc_remove_storefront_breadcrumbs');
    
    

    But as soon as you want to remove the breadcrumb on certain pages only, it does not work.

    
    function wc_remove_storefront_breadcrumbs() {
      if ( is_page (44) ) {
    remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10 );
    }
    }
    add_action( 'init', 'wc_remove_storefront_breadcrumbs');
    
    

    Is there a bug somewhere or is it just better to remove it completely and use yoast?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @francoisduroy,

    I see from this thread here:

    https://www.ads-software.com/support/topic/storefront-woocommerce-breadcrumb-remove-action-not-working-with-conditionals/

    that you are going to go with Yoast, which is excellent. We were able to work with the code and found this to work:

    function wc_remove_storefront_breadcrumbs() {
        if ( is_page(424) ){
            remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10 );
        }
      }
      add_action( 'wp', 'wc_remove_storefront_breadcrumbs');

    The problem is that the way it was as it was checking for an is_page on init or before the page even loaded so WP had no idea. Hooking into wp makes this run after the page is there so it knows, and correctly removes the page from the breadcrumb.

    If you need anything related to the breadcrumbs with Storefront feel free to respond to this thread so that we keep it in Storefront.

    Have a super day!

    Thread Starter Alberto Balsalm

    (@francoisduroy)

    Hello @nixiack8

    Thanks a lot for the reply.

    You are right, I should have thought of that. So stupid.

    Have a great day too.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Storefront woocommerce breadcrumb : remove action not working with conditionals’ is closed to new replies.