Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?

Boohoo why did I start a bounty for that 😉 The answer is pretty simple – add ‘type’ => ‘numeric’ to the meta query.

array(5) {
  ["posts_per_page"]=>
  int(6)
  ["orderby"]=>
  array(2) {
    ["uss_product_price"]=>
    string(4) "DESC"
    ["uss_product_weight"]=>
    string(4) "DESC"
  }
  ["meta_query"]=>
  array(3) {
    ["relation"]=>
    string(3) "AND"
    ["sortprimary_clause"]=>
    array(3) {
      ["key"]=>
      string(17) "uss_product_price"
      ["compare"]=>
      string(6) "EXISTS"
      ["type"]=>
      string(7) "numeric"
    }
    ["sortsecondary_clause"]=>
    array(2) {
      ["key"]=>
      string(18) "uss_product_weight"
      ["compare"]=>
      string(6) "EXISTS"
    }
  }
  ["paged"]=>
  string(1) "1"
  ["post_type"]=>
  string(7) "product"
}