skip to Main Content

Precisely speaking, I want to change the place of breadcrumbs in category pages.
so I check if it is_product_category() and then remove_action ('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 ) and add_action( 'woocommerce_before_shop_loop', 'woocommerce_breadcrumb', 15 );

but apparently it’s not the solution, since it doesn’t work.
Note that it adds the action but doesn’t remove it and two breadcrumbs are showing on the pages.
Your recommendations are appreciated

2

Answers


  1. You can try this
    
    
    
        
      add_action( 'init', 'my_removal_function');
            function my_removal_function() {
            if ( is_product_category() ) {
            remove_action ('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
            add_action( 'woocommerce_before_shop_loop', 'woocommerce_breadcrumb', 15 )
        }
    }
    
    Login or Signup to reply.
  2. You need to apply the condition before the first hook priority.

    add_action( 'woocommerce_before_main_content', 'adjust_breadcrumb', 10 );
    
    function adjust_breadcrumb() {
    
       if ( is_product_category() ) {
           remove_action ('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
           add_action( 'woocommerce_before_shop_loop', 'woocommerce_breadcrumb', 15 )
       }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search