Overide enqueue in non plugable function via child theme

I am trying to override a non-plugable function using the information on this page but it seems to have no effect. Can anyone see what’s wrong.

My code is

remove_action('wp_print_styles', 'az_enqueue_dynamic_css');

function childtheme_dynamic_css() {
    /* I don't need to actually add anything so this is just a placeholder */
}

add_action( 'wp_print_styles', 'childtheme_dynamic_css' );

Solutions Collecting From Web of "Overide enqueue in non plugable function via child theme"

My guess would be that you are remove the action before it is actually being added in the parent theme.

The parent’s theme functions.php file gets loaded after the child one so it looks like your removing something that is not there yet.

The 3rd parameter in remove_action() is the priority. Try playing around with that number – the default is 10 – to see if there is any change.

remove_action() also returns a boolean so you can debug it with

var_dump( remove_action('wp_print_styles', 'az_enqueue_dynamic_css') );

I am assuming as well that you have the action and method names exactly as they appear in the parent theme 🙂

Hope this helps