1

In a parent theme (Foodica Pro) functions.php I have function foodica_scripts(), where css and js are loaded in page header, including:

wp_enqueue_style( 'media-queries', get_template_directory_uri() . '/css/media-queries.css', array(), WPZOOM::$themeVersion );

This media-queries.css will take a lot of work to overwrite (using different breakpoints). I want to avoid loading this css file, but without touching parent theme. Is there any way to do it in child theme only?

1

In your child theme (which I am assuming you are using) functions.php file:

function wpse_356175_assets() {

    wp_dequeue_style( 'media-queries' );

}

add_action( 'wp_enqueue_scripts', 'wpse_356175_assets' );

Utilise wp_dequeue_style and or wp_deregister_style depending on how the stylesheet was registered/enqueued.

If necessary adjust the priority of your action to fire after the registered/enqueued file from the parent theme, e.g:

add_action( 'wp_enqueue_scripts', 'wpse_356175_assets', 100 );

Useful documentation:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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