I would like to sort my custom events by event date and then start time. Below is my current code:
$startDate = $_POST['startDate'];
$endDate = $_POST['endDate'];
$eventType = $_POST['eventType'];
$args = array(
'post_type' => 'event',
'meta_key' => 'event_date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'event_date',
'value' => array( $startDate , $endDate ),
'compare' => 'BETWEEN'
),
array(
'key' => 'event_type',
'value' => $eventType,
'compare' => 'LIKE',
)
)
);
$the_query = new WP_Query( $args );
How do I also order by start time?
Thanks!
Matt
That worked thanks! Just added
'orderby' => array(
'event_date' => 'ASC',
'time_start' => 'ASC'
),
Matt
hi mdfarver, I trying to do something similar but it’s not working for me.
Can you paste the entire args array code?
What WP version are you using? This only works on 4.2? I’m on 4.1.8…
Thank’s in advance!
I’m also having an issue with this using 4.4. It definitely worked with 4.2, not sure if something change in 4.4 or maybe 4.3
Thank’s for your reply.
After update to 4.2 seems it’s working.