Remove parent theme action in child

The question:

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!

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

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

Method 2

@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 );

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment