Support

Account

Home Forums General Issues Pre Get Posts Query – Sort results 2 meta Fields Reply To: Pre Get Posts Query – Sort results 2 meta Fields

  • 
    $meta_query = array(
      'relation' => 'AND',
      'date_clause' => array(
          'key' => 'date_field_name',
          'compare' => 'EXISTS'
       ),,
      'time_clause' => array(
          'key' => 'time_field_name',
          'compare' => 'EXISTS'
       ),
    );
    $query->set('meta_query', $meta_query);
    $orderby = array(
      'date_clause' => 'ASC',
      'time_clause' => 'ASC'
    );
    $query->set('orderby', $orderby);