Home Forums Backend Issues (wp-admin) Query Date Picker by Date then Time Reply To: Query Date Picker by Date then Time

  • In an interesting twist of fate, I’m doing this exact thing for my client as well – so I’ll update this and confirm if the above works, or if not, what I did instead.


    Ignore my previous post, I found a more practical way of doing this here:

    WP core have revamped the orderby function to accept array inputs, so after a bit of poking around, this is the method that I’ve used and confirmed:

    $todays_date = current_time('Ymd');
    $args = array(
        'post_type' => 'events',
        'posts_per_page' => '-1',
        'meta_query' => array(
            'relation' => 'AND',
            'date_clause' => array(
                'key' => 'event_date',
                'compare' => '>=',
                'value' => $todays_date,
            'time_clause' => array(
                'key' => 'event_time',
                'compare' => 'EXISTS',
        'orderby' => array(
            'date_clause' => 'ASC',
            'time_clause' => 'ASC',