Created
July 12, 2013 18:01
-
-
Save sscovil/5986445 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// Use WP_User_Query to grab an array of user IDs. | |
$user_query = new WP_User_Query( array( | |
'fields' => 'ID' | |
) ); | |
$user_ids = $user_query->get_results(); | |
// Loop through each user ID. | |
foreach( $user_ids as $user_id ) { | |
// Use get_userdata() to get a user object with info stored in the 'user' database table. | |
$user_object = get_userdata( $user_id ); | |
echo | |
get_avatar( $user_id ) | |
. '<h1>' | |
. $user_object->display_name | |
. '</h1>' | |
. '<div class="biography">' | |
// Use get_user_meta() to grab individual bits of data stored in the 'usermeta' database table. | |
. get_user_meta( $user_id, 'description', true ) | |
. '</div>' | |
; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was written as an example for my blog post: http://blog.shaunscovil.com/post/55272793162/the-difference-between-get-user-meta-and-get-userdata