0

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 Answers2

0
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 )
    }
}
tiny
  • 447
  • 4
  • 18
0

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 )
   }
}
Ash0ur
  • 1,505
  • 2
  • 8
  • 11