Ordering User Query by Numeric Custom Field
-
My users have a custom field named badge_number. When I try to sort by that custom field using meta_value it ends up sorting like:
1
10
11
2
20When I try to do meta_value_num it doesn’t work at all and just reverts to the default sort.
Here is my code:
$users = get_users(array( 'role' => 'subscriber', 'orderby' => 'meta_value', 'meta_key' => 'badge_number', 'order' => 'ASC' ));Here’s the link to see how it is sorting: http://freshsandbox.com/grrotary/?page_id=2
Is there a different way to do this?
Thanks
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
The topic ‘Ordering User Query by Numeric Custom Field’ is closed to new replies.