Reputation: 13
I'm trying to order a list of users by their mycred balance (integer) but this value is saved as string on database
$args = array(
'orderby' => 'mycred_default',
'order' => 'desc'
);
$users = get_users( $args );
How can I convert this string to integer before the query? or can I do it inside the query?
Upvotes: 1
Views: 43
Reputation: 2227
Probably using meta_value_num could solve the issue
$args = [
'meta_key' => 'mycred_default',
'orderby' => [ 'meta_value_num' => 'DESC' ],
'order' => 'desc',
];
$users = get_users( $args );
Upvotes: 1