Event Listing excluding a category and listing showing only that category

Home Forums Calendar Products Events Calendar PRO Event Listing excluding a category and listing showing only that category

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #43798
    Jeff
    Participant

    We’ve created a separate page for logged in members and we want to show them a calendar with events from only one category. Then on the main site we want to exclude that category from the event list. I’ve been searching but can’t seem to find the answer! Is this possible?

    Thanks for your help.

    #43817
    Jonah
    Participant

    Hi Jeff,

    There’s a few ways you could do this.

    1. You could simply use the built in functionality for event categories that all utilize their own URL – i.e. http://yourdomain.com/events/category/category-slug/ – you would just need to figure out how people get to those pages…
    2. You could modify the query using a function similar to this based upon whether a user is logged in or not: https://gist.github.com/jo-snips/2270007 – this will just affect the grid view so you would need to add another condition for list view. You’ll also want to change the arguments to include (or not include) your categories that you want to include/exclude.

    Does that help?

    – Jonah

    #44196
    Jeff
    Participant

    That helps a lot! I am able to hide the category we don’t want from the month view, but when I change the eventDisplay to ‘list’ it doesn’t do anything. I duplicated the month view function and gave it a new name, changed ‘month’ to ‘list’. Is this the right way? Please let me know if I should be more specific.

    #44214
    Jonah
    Participant

    Hi Jeff,

    Sorry, I misled you. There is no eventDisplay ‘list’, only ‘past’ and ‘upcoming’. I’ve updated my gist with these args in place: https://gist.github.com/jo-snips/2270007

    Let me know whether or not that works.

    – Jonah

    #44288
    Jeff
    Participant

    Hi Jonah,
    Thanks! This works great except now it clears those events from EVER displaying. So my solution that involved the events category page no longer works. With this way in mind, is there a way to separately display just that single category (that is excluded from the main calendar). I had been using jquery to pull the div from that category page.

    Thanks for all your help!

    #44290
    Jonah
    Participant

    Hi Jeff,

    What about adding another condition to say “if we’re on this category page” don’t exclude the category, otherwise exclude it. Something like this:


    if ( !is_tax( 'your_category_slug' ) && $query->query_vars['eventDisplay'] == 'upcoming' ||
    $query->query_vars['eventDisplay'] == 'past' ||
    $query->query_vars['eventDisplay'] == 'month' &&
    $query->query_vars['post_type'] == TribeEvents::POSTTYPE &&
    !is_tax(TribeEvents::TAXONOMY) &&
    empty( $query->query_vars['suppress_filters'] ) ) {

    That will detect to make sure you’re not on that specific event category page and modify the query as desired.

    Does that work?

    #44292
    Jeff
    Participant

    Yes! Thanks Jonah. But the added condition should be:
    !is_tax( ‘tribe_events_cat’, ‘your_category_slug’ )

    #44294
    Jonah
    Participant

    Ahh yes, thanks for pointing that out Jeff. So are you all set here?

    – Jonah

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Event Listing excluding a category and listing showing only that category’ is closed to new replies.