List all the ‘Authors’, with WP_User_Query
Introduced in WordPress 3.1, the WP_User_Query class allows you to query the wp_users, and wp_usermeta tables. This allows you to create lists of authors that match a certain criteria (in this example, the role of author), and display information about each user.
The following code lists all the ‘Authors’, showing for each author its Gravatar, name with a link to an archive of their posts, and their bio.
$args = array(
'role' => 'Author'
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
echo get_avatar($user->ID);
echo '<p><a href="'.home_url().'/author/'.$user->user_nicename.'">' . $user->display_name . '</a></p>';
$description = get_user_meta($user->ID, 'description', true);
echo "<p>Bio: $description</p>";
}
} else {
echo 'No users found.';
}