Using Venues for Related Events

The Related Events feature of Events Calendar Pro allows you to display additional upcoming events on your single events pages, based on the event category. If you're not using event categories or simply find it more useful to show your users other events happening at the same venue, this snippet is here to help!
function tribe_modify_related_posts_args ( $args ) {
	$venue_id = tribe_get_venue_id();
	
	if ( $venue_id ) {
		unset( $args['tax_query'] );
		$args['meta_query'] = array(
			'relation' => 'AND',
			array(
				'key' => '_EventVenueID',
				'value' => $venue_id,
				'compare' => '=',
			)
		);
	}

	return $args;
}
add_filter( 'tribe_related_posts_args', 'tribe_modify_related_posts_args' );
Add this to the functions.php file of your child theme, and voila! Your Related Events section will now display upcoming events by venue.

Plugins

Events Calendar Pro

Notes

  • Originally written in May 2019
  • Tested with The Events Calendar 4.9.2 and Events Calendar Pro 4.7.2
  • Author: Jennifer

Disclaimer

As with all of our recipes, please note that we share this in the hope it will be useful but without any guarantees or commitments. If you wish to use it, it is your responsibility to test it and adapt it to your needs (or find someone who can do so on your behalf). We are unable to provide further support in relation to this recipe.