18

I'm creating a child theme from Storefront.

Now I want to remove these action in child theme

add_action( 'woocommerce_before_shop_loop','storefront_sorting_wrapper',9 );

by this function:

add_action( 'after_setup_theme','remove_action', 100 );
  function remove_action() {
    remove_action( 'init', 'woocommerce_before_shop_loop');
  }

but it doesn't work!

2 Answers 2

31

For removing an action hook you should use the same action name, callback name and the priority that was used to add a action in parent theme. And register it on init

add_action( 'init', 'remove_my_action');
function remove_my_action() {
     remove_action( 'woocommerce_before_shop_loop','storefront_sorting_wrapper',9 );
}

Read about remove_action

1
  • Thanks, I spent an hour looking for the correct answer, this worked.
    – Mahbub
    Oct 24, 2022 at 10:59
8

@Sumit is right, but if you call your function remove_action() Wordpress will throw an error. So this will work:

add_action( 'init', 'remove_actions_parent_theme');

function remove_actions_parent_theme() {
     remove_action( 'storefront_header','storefront_skip_links',0 );
};
1
  • Thanks for the notice @Drik corrected. I just copied from OP :D
    – Sumit
    May 4, 2018 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.