Quantcast
Channel: Question and Answer » meta-query
Viewing all articles
Browse latest Browse all 36

WP_User_Query from meta_key and orderby secondary meta_key

$
0
0

I have this code, which works as intended, but now I want to order these by another meta_key. I’ve tried using meta_query to get another key into the mix, but am still unsuccessful.

I want to get all users where meta_value => $region_id in meta_key => multi_broker_region, then orderby => meta_value_num in meta_key => broker_Order.

How would I go about solving that?

$user_query = new WP_User_Query(
    array(
        'meta_key'   => 'multi_broker_region',
        'meta_value' => $region_id,
        'order'      => 'ASC',
    )
);
$aUsers = $user_query->get_results();
return $aUsers;

Viewing all articles
Browse latest Browse all 36

Trending Articles