1

I'm trying to Deregister and Dequeue 3 Stylesheets from a Plugin (WP Listings) and Enqueue 3 Stylesheets within my Child Theme's directory.

I have tried using the following code, but all 3 of the plugins stylesheet still load before the child stylesheets.

Here's the code I've tried:

//* Load WP Listings Style Sheet from Child Theme
add_action( 'wp_enqueue_scripts', 'load_alta_styles' );

function load_alta_styles() {

wp_dequeue_style( 'wp_listings' );
wp_deregister_style( 'wp_listings' );

wp_dequeue_style( 'wp_listings_widgets' );
wp_deregister_style( 'wp_listings_widgets' );

wp_dequeue_style( 'wp_listings_single' );
wp_deregister_style( 'wp_listings_single' );

wp_enqueue_style( 'wp-listings-child', get_stylesheet_directory_uri() . '/css/wp-listings.css' );

wp_enqueue_style( 'wp-listings-widgets-child', get_stylesheet_directory_uri() . '/css/wp-listings-widgets.css' );

wp_enqueue_style( 'wp-listings-single-child', get_stylesheet_directory_uri() . '/css/wp-listings-single.css' );

}

Can anyone point out where I could be going wrong?

Thank you.

  • 2
    Just try using a later/higher priority for add_action(). – kaiser Feb 9 '15 at 15:04
3

As kaiser noted, you probably need a higher priority.

add_action( 'wp_enqueue_scripts', 'load_alta_styles', 20 );

But if not, you can use wp_style_is to check and see after you do things if they are as expected.

e.g. you might try:

if ( wp_style_is( 'wp_listings_single', 'enqueued' ) ) {
   wp_dequeue_style( 'wp_listings_single' );
   echo '<p>Seems to have been dequeued</p>';
   if ( wp_style_is( 'wp_listings_single', 'enqueued' ) ) {
       echo '<p>But actually was not</p>';
   }
} else {
   echo '<p>wp_listings_style was not actually enqueued ... </p>';
}

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.