Exclude A Certain Category of Events showing in Calendar View

Home Forums Calendar Products Events Calendar PRO Exclude A Certain Category of Events showing in Calendar View

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1471353
    Peter
    Participant

    Dear Sirs,

    I want to exclude certain categories of events in the calendar view but show on a separate listing page. I have found the following associated code see below from GIST:

    // Removes categories “dance” and “concert” from list and month views
    add_action( ‘pre_get_posts’, ‘exclude_events_category’ );

    function exclude_events_category( $query ) {

    if ( $query->query_vars[‘eventDisplay’] == ‘list’ && !is_tax(Tribe__Events__Main::TAXONOMY) || $query->query_vars[‘eventDisplay’] == ‘month’ && $query->query_vars[‘post_type’] == TribeEvents::POSTTYPE && !is_tax(Tribe__Events__Main::TAXONOMY) && empty( $query->query_vars[‘suppress_filters’] ) ) {

    $query->set( 'tax_query', array(
    
        array(
            'taxonomy' => Tribe__Events__Main::TAXONOMY,
            'field' => 'slug',
            'terms' => array('dance', 'concert'),
            'operator' => 'NOT IN'
        )
        )
    );
    

    }
    return $query;
    }

    Can you please tell me where this should be placed as I am not sure

    Many thanks

    #1471549
    Peter
    Participant

    Looki

    #1472350
    Patricia
    Member

    Hi Peter,

    Thank you for reaching out to us!

    You can place this snippet in a custom plugin or in your theme’s functions.php file.

    https://gist.github.com/jesseeproductions/a467b28a8b8010d4015b

    Let me know if you have any other questions in the mean time

    Patricia

    #1491850
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Exclude A Certain Category of Events showing in Calendar View’ is closed to new replies.