On my site I allow users to “bookmark” upcoming events.
They have a page they can view that would show them all these saved events.
How do I select events based on the event ID’s ?
Thanks
Robb

VERB Interactive
Hi Robb,
These bookmarked events – in the case of recurring events do they book mark the entire event or specific occurrences? If the they are bookmarking an entire event series, or if you only have single events, you can simply use the post__in
argument with the event (post) ID:
$events = eo_get_events(array(
'post__in' => array( ... ), //array of event (post) IDs
));
Otherwise for specific occurrences you can use event_occurrence__in
argument with the event’s occurrence ID
$events = eo_get_events(array(
'event_occurrence__in' => array( ... ), //array of event (occurrence) IDs
));
Both can be used with WP_Query
or get_posts()
, if you prefer, but you will need to set post_type
to event
and supress_filters
to false
. (eo_get_events()
is a thin wrapper for get_posts()
).

Stephen Harris
Thanks for writing back.
How do I write to get events by id (post_id) but not get all the occurrences?
I tried:
group_event_by -> ‘ID’
‘showrepeats’ => 0
Both of which do not seem to do anything actually having traced them in the code.
Thanks for your time.
Robb

VERB Interactive
Got it.
‘group_events_by’ => ‘series‘
So you can use:
$events = new WP_Query( array(
'post_type'=> 'event',
'post__in' => $arrayOfIds,
'suppress_filters'=>FALSE,
'numberposts'=>-1,
'orderby'=> 'eventstart',
'order'=> 'ASC',
'showrepeats'=>1,
'group_events_by'=>'series',
'showpastevents'=>TRUE
)
);
Or…
$events = eo_get_events(
array(
'post__in' => $arrayOfIds,
'group_events_by'=>'series'
)
);

VERB Interactive
Hi Robb,
Yes you can use both. Though the form returns a WP_Query
instance and the latter an array of post objects. Which you prefer to use is largely down to personal preference, and the fact that tehre are some functions (e.g. the_content()
) which have to be used ‘inside the loop’ (i.e. using WP_Query
). But there are ways around that: http://stephenharris.info/get-post-content-by-id/

Stephen Harris