Support

Account

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

  • Hi @svsdnb,

    No – I hadn’t done, but you could effectively just add that to the code to replace the meta query that checks that time EXISTS with something more akin to the date check.

    
    $todays_date = current_time('Ymd');
    $right_now = current_time('Hi');
    $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' => '>=',
                'value' => $right_now,
            ),
        ),
        'orderby' => array(
            'date_clause' => 'ASC',
            'time_clause' => 'ASC',
        )
    );
    

    I have yet to look at the Time picker field as part of the latest version, but something akin to that should work fine.