Cannot dequeue styles

Home Forums Calendar Products Events Calendar PRO Cannot dequeue styles

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #887856
    Allen Presher
    Participant

    I’m using the latest Events Calendar and Events Calendar Pro plugins (3.8.1) on a WordPress 4.0 install. Currently there are stylesheets that load on every page, I’d like to remove them for non-events-related pages. I have attempted everything I’ve found posted in these forums, such as:

    function enqueue_scripts_styles() {
    // Load main stylesheet
    wp_enqueue_style( ‘main-stylesheet’, get_stylesheet_uri() );

    // Dequeue events calendar stylesheets
    wp_dequeue_style( ‘tribe-events-full-pro-calendar’ );
    wp_dequeue_style( ‘tribe-events-calendar-pro’ );
    wp_dequeue_style( ‘tribe-events-calendar-full-pro-mobile’ );
    wp_dequeue_style( ‘tribe-events-calendar-pro-mobile’ );
    }
    add_action( ‘wp_enqueue_scripts’, ‘enqueue’ );

    The above does not work to remove these styles (I’ll add logic later to target what pages I want to remove them on). I’ve tried just about every permutation imaginable, has the method to remove these stylesheets changed or could I be provided with an example of how best to accomplish this?

    Thank you!

    #887930
    Casey
    Participant

    stratejusinc,
    Thanks for getting in touch! You should be able to use the following code in your theme’s functions.php to dequeue all Events Calendar styles: https://gist.github.com/ckpicker/ffe7c737b73e5d581bad

    The main thing you’ll want to note is that I’ve set the priority of the ‘dequeue_tribe_styles’ function to 100, so that it is executed after the plugin enqueues the styles. You’ll also want to keep in mind that this will remove styling from all pages on your site, including your Event pages, unless you add some logic to only dequeue styles on non-event pages.

    Give that code a try and let me know if it does the trick for you.

    Thanks! 🙂

    -Casey-

    #888007
    Allen Presher
    Participant

    Worked like a charm, thank you. On a quick side-note is there any singular function I can check against to see if a page is any one of the events calendar pages? Right now I’m saying:

    if ( !tribe_is_month() && !tribe_is_event() ) :
    //DEQEUE STYLES
    endif;

    Not sure if there is one singular thing I can test against? Other than that thank you again!

    #889420
    Casey
    Participant

    stratejusinc,
    Unfortunately not. You’ll definitely want to utilize all of the conditional functions to make sure that you’re not dequeueing the CSS on pages that need it (Event Views, Organizer archives, Venue archives, etc). Take a look at our documentation and look for the ‘tribe_is_*’ functions (ex: tribe_is_upcoming).

    Glad that did the trick for you, and let me know if you need further help. Thanks! 🙂

    -Casey-

    #983592
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Cannot dequeue styles’ is closed to new replies.