I’m using this function to calculate the event duration in days and display it above the booking form.
$curr_start_date = eo_get_the_start('Ymd', $event_id);
$curr_end_date = eo_get_the_end('Ymd', $event_id);
$event_duration_days = ($curr_end_date - $curr_start_date) +1;
$days_suffix = $event_duration_days > 1 ? "Days" : "Day";
echo "Event length is "."event_duration_days." ".$days_suffix;
On the event page everything works fine but I’m also using the booking form via shortcut in posts and there eo_get_the_start(‘Ymd’, $event_id); returns false.
I’m aware that this may be related to this post:
eo_get_the_start-not-working-anymore-on-update
Obviously I should feed the fourth argument with the occurrence id like that:
eo_get_the_start('Ymd', $event_id, null,$post->occurrence_id);
But I’m on an other page and $post->occurrence_id will deliver nothing. Now I’m stucked. Any idea how to get the occurrence id?

Adrian Maleska
Since all occurrences of an event have to be the same length you can simply pick one. You can get an array of occurrence IDs for an event by following this thread: http://wp-event-organiser.com/forums/topic/get-occurrence-id/. To get one occurrence ID, just use array_pop
or array_shift
. (for the last / first ID).

Stephen Harris
Oh I see, now it’s clear to me. I made a function out of it for later usage:
echo "Next occurrence_id is: ".get_closest_occurrence_id($this_event_id);
function get_closest_occurrence_id($event_id)
{
$occurrences = eo_get_the_occurrences_of( $event_id );
if($occurrences)
{
$occurence_ids = array_keys( $occurrences );
return $occurence_ids[0];
}
else
return null;
}
Thanks a lot Stephen!

Adrian Maleska