Elementor custom query order by date AND 2 numeric custom fields asc and desc

Question

i want to sort my posts by

  • date (last)
  • score_points (DESC)
  • score_seconds (ASC)

the last posts , order by highest point and lowest seconds

  add_action( 'elementor/query/filter_by_highscoreandtime', function( $query ) {
     $query->set( 'meta_query', [
    'relation' => 'AND',
    'date_clause' => [ // named clause
        'key' => 'date',
        'type' => 'DATE',
        'compare' => 'IN',
    ],  
    'points_clause' => [ // named clause
        'key' => 'score_points',
        'compare' => 'EXISTS',
        'type' => 'NUMERIC',
    ],
    'seconds_clause' => [ // named clause
        'key' => 'score_seconds',
        'compare' => 'EXISTS',
        'type' => 'NUMERIC',
    ], 
   ] );
     $query->set( 'orderby', [
    'date_clause' => 'DESC',
    'points_clause' => 'DESC',
    'seconds_clause' => 'ASC',
] );
 } );

but it doesnt work. the date throws an error or is ignored!
Any idea?

thank you

0
Patrick Duke Schauer 3 weeks 2021-07-06T03:02:11-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse