Remove Category from Calendar and List Views

Home Forums Calendar Products Events Calendar PRO Remove Category from Calendar and List Views

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1577206
    Melanie Adcock
    Participant

    I scoured the forum looking for some code to do this. I found the following but now it is throwing an error but I don’t understand the error:
    The error:
    Notice: Undefined index: eventDisplay in /nas/content/staging/newleaderdog/wp-content/themes/leaderdog_child/functions.php on line 181

    The code:
    / Removes categories “puppy raisers” from list and month views
    add_action( ‘pre_get_posts’, ‘exclude_events_category’ );
    function exclude_events_category( $query ) {
    if ( ! is_singular( ‘tribe_events’) && ! is_page(3434) && $query->query_vars[‘eventDisplay’] == ‘list’ && !is_tax(TribeEvents::TAXONOMY) || $query->query_vars[‘eventDisplay’] == ‘month’ && $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(‘puppy-raisers’),
    ‘operator’ => ‘NOT IN’
    )
    )
    );
    }
    return $query;
    }

    Thanks.
    Melanie

    #1577490
    Cliff
    Member

    Hi, Melanie.

    I didn’t review all of your code, but that error means you should add a check if eventDisplay is empty, like this:

    if ( ! is_singular( 'tribe_events') && ! is_page(3434) && ! empty( $query->query_vars['eventDisplay'] ) && ...

    (or, if that that, then something close to it)

    Please let me know how this goes for you.

    #1593068
    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 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Remove Category from Calendar and List Views’ is closed to new replies.