I have wp_users table which has a column ordering. I came to know that get_users() returns all the users.
I am using it like get_users('orderby=ordering')
I got help form this link
But unfortunately it is not sorting on ordering column. Any help?
You should first take a look at the users table from the database. The command you try is good, but the argument you use for ordering might be wrong. You should order by a column from the users table, for example user name, or user id's..
On the link you mentioned I've found these:
orderby - Sort by 'ID', 'login', 'nicename', 'email', 'url', 'registered', 'display_name', or 'post_count'.
order - ASC (ascending) or DESC (descending).
Some working examples:
Get users by nicename:
$users = get_users('orderby=nicename');
Other examples:
Display users sorted by Post Count, Descending order
$user_query = new WP_User_Query( array ( 'orderby' => 'post_count', 'order' => 'DESC' ) );
Display users sorted by registered, Ascending order
$user_query = new WP_User_Query( array ( 'orderby' => 'registered', 'order' => 'ASC' ) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With