This code is no longer up-to-date. Please check out “An Even Better Author List in WordPress” for a better approach.
WordPress has a built in function to display a list of all of your site’s authors. But there is no option to display their avatars, so all you really get is a text list that links to the author’s page, if you have an author.php file in your theme, that is. I needed to also display the authors’ avatars for a client so I came up with a little piece of code that seems to do the trick.
NOTE: The old piece of code only worked if you were using pretty permalinks, and it was a little clunky.
function contributors() { global $wpdb; $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name"); foreach($authors as $author) { echo "
';
echo "ID;
echo "\">";
the_author_meta('display_name', $author->ID);
echo "";
echo "
";
echo "I also had to add some CSS to my style.css file to make it look the way I wanted.
#authorlist li { clear: left; float: left; margin: 0 0 5px 0; } #authorlist img.photo { width: 40px; height: 40px; float: left; } #authorlist div.authname { margin: 20px 0 0 10px; float: left; }
NOTE: If you are using the User Photo plugin you can replace echo get_avatar($author->ID);
with echo userphoto($author->ID);