Add meta query to default calendar view

Home Forums Calendar Products Events Calendar PRO Add meta query to default calendar view

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1182719
    sparxoo
    Participant

    Hi,

    I’m trying to add a meta query to the default calendar template. Basically I’m creating a website where each user is a part of a club and each club has their own events. So for instance the user is in club 100, I need to only grab events that belong to club 100. I have added a custom field to the events in order to add the club number, i’m just wondering if there’s a way to query the posts on the default view without having to use tribe_get_events and creating my own template.

    #1183378
    Nico
    Member

    Hi there @sparxoo,

    Thanks for getting in touch with us! I can help you on this ๐Ÿ™‚

    I’m not 100% sure that I understand correctly what you are trying to do here, but I guess it’s just modifying the calendar main query. Take a look at the code sample below:

    /* Tribe, limit posts just to a category */
    add_action( 'pre_get_posts', 'limit_events_category' );
    function limit_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('results'),
    'operator' => 'IN'
    )

    ));

    }
    }

    It’s just a starting point but I guess it will give you the base to craft your customization!

    Please let me know about it,
    Best,
    Nico

    #1183907
    sparxoo
    Participant

    Awesome, this is exactly what I was looking for. I just swapped out tax_query for a meta_query and it worked great. Thanks!

    #1184058
    Nico
    Member

    Hey @sparxoo! Stocked to hear you could make it work for your site ๐Ÿ™‚

    Iโ€™ll go ahead and close out this thread, but if you need help with anything else please donโ€™t hesitate to create a new one and we will be happy to assist you.

    Best,
    Nico

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Add meta query to default calendar view’ is closed to new replies.