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!
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
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 stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0