Posted: August 15, 2013 at 4:45 pm
|
Hi. I have a page with a list of events ordered by the start date, but not the start time: http://dppad.com/demo/orlandophil/?page_id=24 The code that produces this list is: <code>global $post, $wp_query; // define some arguments for our Event Espresso query $args = array( 'post_type' => 'espresso_event', 'meta_key' => 'event_start_date', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'event_start_date', 'value' => date('Y-m-d'), 'compare' => '>=', // compares the event_start_date against today's date so we only display events that haven't happened yet 'type' => 'DATE' ) ), 'orderby' => 'meta_value', 'order' => 'ASC' // change this to ASC if you want newer events on top );</code> Can you recommend a modification to the query that will order the events by start date, but also by start time (so that matinee performances will appear before their corresponding evening performance). Thanks. |
|
I think you would have to change line 506 of includes/event-management/insert_event.php to: add_post_meta($post_id, 'event_start_date', $start_date . ' ' . date("H:i", strtotime($start_time))); and line 616 of includes/event-management/update_event.php to: update_post_meta($post_id, 'event_start_date', $start_date . ' ' . date("H:i", strtotime($start_time))); and line 646 of the same file to: add_post_meta($post_id, 'event_start_date', $start_date . ' ' . date("H:i", strtotime($start_time))); and line 22 of post-type-samples/page-event_list.php to: 'value' => date('Y-m-d H:i'), Then you’ll have to resave your events to get your post data updated. Then it should order the posts by date and time. |
|
Worked like a charm. Any recommendations on accomplishing this in an update-proof way? |
The support post ‘Order by start_date & start_time in wp_query’ 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.