Excluding single category from upcoming view removes category from "my events"

Home Forums Calendar Products Community Events Excluding single category from upcoming view removes category from "my events"

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #985503
    Katie
    Participant

    Hello.

    I am trying to exclude a single category from our upcoming/month view pages. Here is the code I have in my theme’s functions.php file, as per other forum topics:

    add_action( 'pre_get_posts', 'exclude_events_category' );
    function exclude_events_category( $query ) {
    
      if ( $query->query_vars['eventDisplay'] == 'upcoming' || $query->query_vars['eventDisplay'] == 'past' || $query->query_vars['post_type'] == TribeEvents::POSTTYPE && !is_tax(TribeEvents::TAXONOMY) && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set( 'tax_query', array(
          array(
            'taxonomy' => TribeEvents::TAXONOMY,
            'field' => 'slug',
            'terms' => array('yard-sales'),
            'operator' => 'NOT IN'
          )
        ) );
      }
    
      return $query;
    } 

    However, this also removes ‘yard-sales’ category events from the front-end user’s “My Events” page. Since we are only using the Community Events add-on to allow people to post yard sales, which we’re trying to display separately from our main events calendar, this is an issue.

    Is it possible to exclude the category from the main upcoming events page AND display it on the front-end user’s “My Events” page?

    Thanks for your help.

    #985587
    Josh
    Participant

    Hey Katie,

    Thanks for reaching out to us!

    We do have a conditional which can be added to the conditionals within your snippet that you have provided for targetting the “My Events” loop. So, if you use “tribe_is_community_my_events_page()” you can check to see if the current view is the My Events view and not run the above code on that view.

    Let me know if this helps.

    Thanks!

    #990251
    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 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Excluding single category from upcoming view removes category from "my events"’ is closed to new replies.