Support

Home Forums Event Espresso Premium Add order by to these Query Params

Add order by to these Query Params

Posted: February 26, 2018 at 3:52 pm

Viewing 2 reply threads


jacl

February 26, 2018 at 3:52 pm

Hi

I’m using this code snippet from your site to show upcoming events after the venue details are output on a venue page but can’t work out how to add a simple order by parameter to this query to get it to show them ordered by start date ASC.

I’ve tried adding ‘order_by’ => ‘Datetime.DTT_EVT_start’, but that threw fatal errors.

Any tips or guidance would be much appreciated thanks ๐Ÿ™‚

function ee_list_upcoming_events_for_a_venue( $post ) {
// query the events for this venue using EE_Venue's events() method
// http://code.eventespresso.com/classes/EE_Venue.html#method_events
$query_params = array(
array(
'status' => 'publish',
'Datetime.DTT_EVT_start' => array(
'>',
date( current_time( 'mysql', true ) ),
'Datetime.DTT_EVT_end' => array(
'<',
date( current_time( 'mysql', true ) )
)
)
)
);

$events = EEH_Venue_View::get_venue( $post->ID )->events( $query_params );


Josh

  • Support Staff

February 26, 2018 at 4:59 pm

Hi jacl,

I updated the code example so now it includes an order_by clause:

https://eventespresso.com/wiki/useful-php-code-snippets/#venue-event-list


jacl

February 27, 2018 at 3:08 am

Hi Josh

So easy when you know how eh ๐Ÿ™‚

Great support thank you so much!

Jonathan

Viewing 2 reply threads

The support post ‘Add order by to these Query Params’ 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.

Event Espresso