Created
August 15, 2012 17:34
-
-
Save wpsmith/3361816 to your computer and use it in GitHub Desktop.
Orderby meta_value last_name via WP_User_Query Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Caveat: This creates 2 queries and any use of this code should also use site transients | |
// prepare arguments | |
$args = array( | |
'meta_key' => 'last_name', | |
); | |
// Create the WP_User_Query object | |
$author_query = new WP_User_Query( $args ); | |
// Modify the WP_User_Query object | |
$author_query->query_orderby = str_replace( 'user_login', 'wpsand_usermeta.meta_value', $author_query->query_orderby ); | |
// Re-query | |
$author_query->query(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment