I'm trying to sort users by a custom meta value "user_business" which is their business name that way when users are listed they're sorted alphabetically by their business name as they should be.

I'm currently using:

                        // WP_User_Query arguments
                        $args = array (
                            'exclude'        => array( 1 ),
                            'count_total'    => true,
                            'fields'         => 'all_with_meta',

                        // The User Query
                        $user_query = new WP_User_Query( $args );

                        // The User Loop
                        if ( ! empty( $user_query->results ) ) {
                            foreach ( $user_query->results as $user ) { ?>

Is there a way that I can order users by meta key "user_business"?

  • This solution will not work for me as it involves adding another custom field which isn't an option seeing as site users will come and go and I don't want to have to edit the meta value for each one every time they need reordered. I want something much more dynamic. – Austin Biggs Jul 8 '13 at 17:35
  • That is not a complete answer for your circumstance-- if I had the time I'd write one-- but using that filter is the approach you need to take. – s_ha_dum Jul 8 '13 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.