Trying to output the next 3 events on the home page. Using this following query
<?php
// Query Arguments
$atts = array(
'limit' => 3,
'post_status' => 'publish',
'show_expired' => FALSE,
'order_by' => 'start_date',
'sort' => 'ASC',
);
// Query
$query = new EE_Event_List_Query($atts);
?>
But regardless of whether I use ‘sort’ => ‘ASC’ or ‘sort’ => ‘DESC’ the events are coming out in the same sort order.
Tried various snippets from the forum but none worked as expected.
Seems like a simple query….so I suspect it’s something simple I’m missing.
Thanks Josh
This gets me most of the way there.
I do need to get the start date for the event and have been unable to get that so far. I tried print_r on the $event array but that did not seem to contain the date.
Can you tell me how to get the start date or perhaps point me to a resource that shows how to get elements out of $event when I use the snippet provided?
You’ll note the third parameter takes the event ID, which you can get from the $event object. So for example the following will echo out the event’s next upcoming datetime using the date and time format set in WP > Settings:
The support post ‘Query sorted by start date’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.