Hi Andy,
Thanks for writing in,
From what I see in your snippet, there are a couple of things to point out.
It will never retrieve multiday events, as it is specifically telling to bring events starting and ending within the same date ($searchDate).
Also, it all depends on the value of $searchDate.This should be assigned with a date without time.
Here is a knowledgebase article that will help you on this: https://support.theeventscalendar.com/666307-Using-tribe_get_events
Please let me know if this helps
Best
Santiago
Thanks for the reply. The thing is that it used to work and worked for quite a while. I’d seen that page and my understanding of it was that start_date and end_date indicated the date range to search within, as described here – https://support.theeventscalendar.com/666307-Using-tribe_get_events/666307-Using-tribe_get_events?r=1#event-specific-arguments
If start_date was the start of the events then the first example would only return events starting on the day passed to the function, not the next 5 events.
Amway I just wondered if anyone had encountered something similar as I can always code around it.
Thanks,
Andy
Hello, I need to do the same thing.
And I search to do it.
For exemple, I need to have all events on Novembre the 16th.
And for multidays events, the events that have a start_date before and a end_date after, must be shown…
Here’s my workaround in case its of any use to anyone. This function returns url and title of events that occur on a specific day, I use it in a calendar.
You’ll just need to adjust the “-3 days” to suit the length of events since tribe_get_events wont return events already in progress. It needs a bit more refinement, like an end date so it doesn’t keep returning a whole year, but hopefully it’ll help someone.
function get_event_link($day,$month,$year)
{
global $post;
$searchDate = mktime(00, 00, 00, $month, $day, $year);
// Retrieve events from the search date -3 days
$events = tribe_get_events( [
'eventDisplay' => 'custom',
'start_date' => strtotime('-3 days',$searchDate)
] );
//loop through the events until an event between the start end end date is found
foreach ( $events as $post ) {
setup_postdata( $post );
$startDate = strtotime(tribe_get_start_date($post->ID, false, 'Y-m-d'));
$endDate = strtotime(tribe_get_end_date($post->ID, false, 'Y-m-d'));
if($searchDate>=$startDate && $searchDate<=$endDate)
return array(tribe_get_event_link($post),$post->post_title);
}
}
Andy