Sort by date, then by time

We have "events" that are specific dates, so the page is set to put the events based on the day of the event first - then they should be sorted by the time the event takes place.

The dates are fine -- all the proper events are under the proper dates.

But the times are not consistent. About 80% of them are correct but every once in a while one falls out of place....so I may see something like this: (DAY 2 shows the issue)

DAY 1
 8:00am - 10:00am event 1
10:15am - 12:00pm event 2
 1:15pm -  2:00pm event 3
 3:15pm -  5:00pm event 4

DAY 2
 8:00am - 10:00am event 1
 3:15pm -  5:00pm event 4
10:15am - 12:00pm event 2
 1:15pm -  2:00pm event 3

This is the code that handles this area - can anyone offer advice on how to get the TIMES in ascending order as well?

echo 'div class="page hentry entry"div class="entry"ul class="conference_list"';
$year_to_show = '2016';

$args = array(
    'posts_per_page' = -1, 
    'meta_key'       = 'date', 
    'order'          = 'ASC', 
    'orderby'        = 'meta_value',
    'post_type'      = 'proposal'
);
$myQuery = new WP_Query( $args );

$date = CFS()-get( 'date' ); 

if ( $myQuery-have_posts() ) : while ( $myQuery-have_posts() ) : $myQuery-the_post();
    if ( date( 'Y', strtotime( CFS()-get( 'date' ) ) ) == $year_to_show ) {
        if ( $date != CFS()-get( 'date' ) ) {
            $date = CFS()-get( 'date' );
            echo 'div class="date_title"';
            echo date( 'F j, Y', strtotime( CFS()-get( 'date' ) ) );
            echo '/div';
        } ?
        lispan?php echo genesis_get_custom_field( 'start_time' ); ?  - ?php 
            echo genesis_get_custom_field( 'end_time' );?   /span

Topic custom-post-types Wordpress

Category Web


You can order by multiple things see more on https://make.wordpress.org/core/2014/08/29/a-more-powerful-order-by-in-wordpress-4-0/:

$args = array(
    'meta_key' => 'start_time',
    'orderby' => array('date' => 'ASC', 'meta_value' => 'ASC)
);

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.