I'm trying to order data with two meta keys but I'm not able to do that.
This code is not working for me:
$args= array(
"post_type" => "post_type",
"post_status" => "publish",
'meta_query' => array(
array(
'key' => 'keyname1',
'orderby' => 'meta_value_num',
'order' => DESC,
),
array(
'key' => 'keyname2',
'orderby' => 'meta_value_num',
'order' => DESC,
),
),
"posts_per_page" => 10
);
This code works for the single key perfectly, but not for the two keys:
$args=array(
"post_type" => "post_type",
"post_status" => "publish",
"orderby" => array(
"meta_value_num" => "DESC",
"rand" => "ASC" ),
"meta_key" => "keyname",);
How can I do this?