• Hi,

    I’m trying to dequeue the stylesheet everywhere except the page with the shortcode.

    Can’t seem to get it to work.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there!

    I guess you are talking about the following stylesheet:

    /wp-content/plugins/wp-store-locator/css/styles.min.css

    If you want to dequeue it from all pages except, say, page with id=1, you could try this code snippet:

    add_action( 'wp_enqueue_scripts', 'custom_dequeue_styles', 11 );
    function custom_dequeue_styles() {
        if (get_the_ID() != 1) {
    		wp_dequeue_style( 'wpsl-styles' );
        }
    }

    Place the above code snippet in your active theme’s functions.php file and replace the “1” in the conditional statement with the id of the post or page where you have used the [wpsl] shortcode.

    I hope that helps!
    Regards,

    Thread Starter Sean Thompson

    (@seanthompson)

    Got it working with:

    function otw_remove_map_style() {
    
        if(!is_page('dealers')) {
            
            wp_dequeue_style( 'wpsl-styles' );
            
        }
    }
    add_action( 'wp_enqueue_scripts', 'otw_remove_map_style', 11 );

    Thank you.

    Cool!

    Yes, I forgot to mention that you could also use the page slug, your solution is even better ??

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Dequeue Stylesheet’ is closed to new replies.