Forum Replies Created
-
AuthorPosts
-
Jason
MemberJonah, you’re right! I wasn’t putting the filter into functions.php. So, I added the code to functions.php, but using $query->set(‘venue’, $venueId) didn’t seem to work for me. I var_dump’d the $query from within the filter, and while the “venue” query_var was being added, and the new $query returned, the TribeEventsQuery class wasn’t seeing the query_var in its setupQuery() method when I var_dump’d the $query there. Very strange.
So, my solution was the following:
add_action( ‘pre_get_posts’, ‘filter_events_by_venue’ );
function filter_events_by_venue( $query ) {
if ($query->query_vars[‘post_type’] === ‘tribe_events’) {
$venue = get_query_var(‘tribe_venue’);
$query->query_vars[‘meta_query’][] = array(‘key’=>’_EventVenueID’, ‘value’=>get_venue_id($venue));
return $query;
}
}Jason
MemberThanks for the reply Jonah!
I thought that may have been the issue, but I completely removed the IF statement, and the same thing is still occurring. For some reason, the “venue” argument is not getting passed properly. I did some debugging in tribe-event-query.class.php, and the setupQueryArgs method is not detecting the “venue” argument at all.I even went so far as to manually set the _EventVenueID in the meta_query with the same result. It’s just not going through.
[code]
add_action( ‘pre_get_posts’, ‘filter_by_venue’ );
function filter_by_venue( $query ) {
$query->set(‘venue’, 12);
return $query;
}
get_header();
[/code]Jason
MemberThis does not work. I added this code to my page template, prior to calling tribe_calendar_grid(), and it still displays all events, regardless of what venue ID I use. I know the venue ID is correct, and I made sure the filter_by_venue() function was running. So, I’m at a loss at to how to accomplish this.
-
AuthorPosts
