Exclude category from month, list, week, day view

Home Forums Calendar Products Events Calendar PRO Exclude category from month, list, week, day view

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #890610
    Chris Titley
    Participant

    Hi there. Thanks for a great bit of kit.

    We run a website for the city of York, UK, with a lot of events to include daily.

    We want to exclude long-running exhibitions from the main list of events (including all the views: list, month, week, day, map) as they dominate to the detriment of new events.

    For readers interested in exhibitions, we would direct them to the specific url where they are listed.

    We have tried adding the code below, as suggested in another thread (’89’ is the ID no of the category ‘Exhibition’, but it didn’t work.

    What are we doing wrong please?

    Best wishes,

    Chris

    add_action( 'pre_get_posts', 'exclude_events_category' );
    
    function exclude_events_category( $query ) {
    
    if ( tribe_is_event() && !tribe_is_day() && !is_single() && !is_tax() && !tribe_is_month() ) {
    
      $query->set( 'tax_query', array(
    
        array(
    
          'taxonomy' => TribeEvents::TAXONOMY,
    
          'field' => 'slug',
    
          'terms' => array('89'),
    
          'operator' => 'NOT IN'
    
        )
    
        )
    
      );
    
    }
    
    return $query;
    
    }
    </pre>
    #891016
    Brook
    Participant

    Howdy Chris,

    Good question. Two problem stand out, first of all this line will exclude the script form running on month views. It sounds like you don’t want that to happen.

    if ( tribe_is_event() && !tribe_is_day() && !is_single() && !is_tax() && !tribe_is_month() ) {

    And the second issue is that you are using the category ID, not it’s slug on this line:

    ‘terms’ => array(’89’),

    I think if you address those two problems it will work from the looks of it. If you are not super familiar with PHP and the WP API, sometimes it is nice to have folks around who can help! We can only do limitted debugging from afar. But hopefully once you address those two issues we will have a happy outcome. Please let me know the result. Thanks!

    – Brook

    #914964
    Brook
    Participant

    Since this has gone for a spell without a response, I am going to archive it. If for some reason your issue is not resolved please open a new topic. We’d love to continue helping. Cheers!

    – Brook

    #914968
    Brook
    Participant

    Since this has gone for a spell without a response, I am going to archive it. If for some reason your issue is not resolved please open a new topic. We’d love to continue helping. Cheers!

    – Brook

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Exclude category from month, list, week, day view’ is closed to new replies.