Fiter category function not working on Week View

Home Forums Calendar Products Events Calendar PRO Fiter category function not working on Week View

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #748744
    smazzoni
    Participant

    Hello again, I’m having some problems to filter a category on the Week View, while the function you posted here on the forums works perfectly

    add_action( ‘pre_get_posts’, ‘exclude_events_category’ );
    function exclude_events_category( $query ) {
    if ( $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(‘nightlife-bars-clubs’),
    ‘operator’ => ‘NOT IN’
    )
    )
    );
    }
    return $query;
    }

    This doesn’t work on the Week View, is there a workaround for this? Thanks!

    #750771
    Barry
    Member

    Hi – thanks for posting.

    That snippet seems to work as expected when I test it, in list view and in week view (no events from my test category displayed).

    Is there any further information you can provide/have you tried it out after deactivating all other plugins and switching to a default theme, as described in our post on looking for conflicts? It could definitely be worth adding this snippet when no other plugins and only a default theme are enabled and seeing if it works then.

    Thanks!

    #750815
    smazzoni
    Participant

    Hi Barry,

    Now I figure out that only works on the Monthly View, isn’t working on Day, Week nor Map view (maybe because these views are built with JS?)

    What I did is to put the function on functions.php of my theme, and calling it at the top of the default-template of the tribe-events folder:

    add_action( ‘pre_get_posts’, ‘exclude_events_category’ );

    Am I doing something wrong?

    #751267
    Barry
    Member

    Yes: please put your add_action() call in your functions.php file, along with the function itself. Does that help?

    #751516
    smazzoni
    Participant

    Working perfectly now, thank you Barry 🙂

    #752876
    Barry
    Member

    My pleasure 🙂

    I’ll go ahead and close this thread as it looks like you’re all sorted – but please don’t hesitate to create new threads as needed if we can assist with anything else.

    Also, if you have a moment, we’d love to hear your thoughts on The Events Calendar across on our plugin review page – thanks again!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Fiter category function not working on Week View’ is closed to new replies.