remove_action on after_setup_theme not working from child theme

I am trying to remove a theme action for an elegant-themes theme using a child theme..
This works when I remove action after add_action code anywhere in the parent theme functions.php.
However, it does not work when I add it from child theme functions.php.

remove_action ('after_setup_theme', 'et_pb_setup_theme' , 10);

Remove action has same priority 10 as the add action. Shouldn’t it work?

add_action( 'after_setup_theme', 'et_pb_setup_theme' ); //parent theme add_action


As @cybmeta already pointed out, you are too early with your removal. So you have to defer the actual removal, for instance like so:

add_action( 'after_setup_theme', 'wpdev_170663_remove_parent_theme_stuff', 0 );

function wpdev_170663_remove_parent_theme_stuff() {

    remove_action( 'after_setup_theme', 'et_pb_setup_theme' );

Leave a Comment