How do I override plugin styles with the child theme style sheet?
-
This is my queuing script:
function my_load_child_theme_styles() { if ( ! defined( 'WPEX_THEME_STYLE_HANDLE' ) ) { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css', array(), '1.0' ); } // First de-register the main stylesheet (which is now your child theme style.css) wp_dequeue_style( WPEX_THEME_STYLE_HANDLE ); wp_deregister_style( WPEX_THEME_STYLE_HANDLE ); // Add the parent style.css with the main style handle wp_enqueue_style( WPEX_THEME_STYLE_HANDLE, get_template_directory_uri() . '/style.css', array(), WPEX_THEME_VERSION ); // Re-add child CSS with parent as dependency wp_enqueue_style( 'child-css', get_stylesheet_directory_uri() . '/style.css', array( WPEX_THEME_STYLE_HANDLE ), '1.0' ); wp_enqueue_style( 'child_media-css', // stylesheet handle get_stylesheet_directory_uri() . '/child_media_600_max.css', // stylesheet file URL array( WPEX_THEME_STYLE_HANDLE ), // dependencies '1.0', // stylesheet version 'only screen and (max-width:600px)' // media query ); wp_enqueue_style( 'child_media-css', // stylesheet handle get_stylesheet_directory_uri() . '/child_media_600_min.css', // stylesheet file URL array( WPEX_THEME_STYLE_HANDLE ), // dependencies '1.0', // stylesheet version 'only screen and (min-width:600px)' // media query ); } add_action( 'wp_enqueue_scripts', 'my_load_child_theme_styles', PHP_INT_MAX );
The problem is that the plugin style sheet doesn’t have any handle.
The child styles are already set as a dependency.
I already have a maximum priority for my child styles set.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How do I override plugin styles with the child theme style sheet?’ is closed to new replies.