How can I show events from multiple venues?
I use this code:
$events = eo_get_events(array(
‘post_type’ => ‘event’,
‘numberposts’=>10,
‘event_start_after’=>’today’,
‘event-venue’ => ‘big-hall’,
‘showpastevents’=>true,
‘suppress_filters’ => false,
));
I have tried different ways, without luck.
Eirik

Eirik Kyrkjeeide
Other question is how to list only categories that has active events. Not past events.
Eirik

Eirik Kyrkjeeide
Hi Eirik,
Venues are taxonomy terms, so you can query events in multiple venues using the tax_query
argument, with taxonomy set to event-venue
. The WordPress codex has examples of the tax_query
argument (note WP_Query()
arguments can be used in eo_get_events()
.
Getting the IDs of categories of events matching a query is not straightforward unfortunately. You could query all future events, and then loop through and pull out their categories, but that’s quite costly.
A better, but more complicated way is to attack it directly with SQL. Please note I haven’t tested the code below, so there maybe mistakes, but it should point in you the right direction.
$now = new DateTime();
$sql = $wpdb->prepare("
SELECT DISTINCT t.*
FROM {$wpdb->prefix}_terms AS t
INNER JOIN {$wpdb->prefix}_term_taxonomy AS tt #Join the taxonomy table to terms...
ON t.term_id = tt.term_id
JOIN {$wpdb->prefix}_term_relationships AS tr #Join posts to the term relationship table
ON tr.term_taxonomy_id = tt.term_taxonomy_id
JOIN {$wpdb->prefix}_posts AS p
ON p.ID = tr.object_id
JOIN {$wpdb->eo_events} AS ev
ON p.ID = ev.post_id
WHERE tt.taxonomy IN ('event-category')
AND p.post_type = 'event'
AND p.post_status = 'publish'
AND ( ev.StartDate > %s OR (ev.StartDate = %s AND ev.StartTime > %s) )
ORDER BY t.name ASC;",
$now->format( 'Y-m-d' ),
$now->format( 'Y-m-d' ),
$now->format( 'H:i:s' )
);
$cats_with_upcoming_events = $wpdb->get_results( $sql );

Stephen Harris