[wp-hackers] Querying users, orderby last name field?

Otto otto at ottodestruct.com
Fri Dec 20 20:38:51 UTC 2013


On Fri, Dec 20, 2013 at 2:25 PM, Josh Pollock <jpollock412 at gmail.com> wrote:

> There doesn't seem to be an orderby option in WP_User_Query to orderby last
> name field. This leaves me wondering why not and what the most direct way
> to do so would be.
>


Does this not work?

new WP_User_Query(array(
   'meta_key'=>'last_name',
   'orderby'=>'meta_value',
));

The last name is not a field that exists in the users table. It's a meta
field. So you have to specify it and then order by the value of it.

-Otto


More information about the wp-hackers mailing list