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.
thus turning the internet I found this nice tutorial bavotasan.com with a little piece of code that seems to do the trick.
On my site all users can write articles and list of contributors is long. Itâs possible set 10 users for page ?
Using this solution: Paginate result set from $wpdb->get_results()
I did make my code for Authors list functions as follow:
function contributors() {
global $wpdb;
$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users WHERE display_name <> 'admin' ORDER BY display_name");
$authors_per_page = 10;
$page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;
echo paginate_links( array(
'base' => add_query_arg( 'cpage', '%#%' ),
'format' => '',
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => ceil($total / $authors_per_page),
'current' => $page
));
foreach ($authors as $author ) {
echo "<li>";
echo "<a href="".get_bloginfo('url')."/author/";
the_author_meta('user_nicename', $author->ID);
echo "/">";
echo get_avatar($author->ID);
echo "</a>";
echo '<div>';
echo "<a href="".get_bloginfo('url')."/author/";
the_author_meta('user_nicename', $author->ID);
echo "/">";
the_author_meta('display_name', $author->ID);
echo "</a>";
echo "<br />";
echo "SitoWeb: <a href="";
the_author_meta('user_url', $author->ID);
echo "/" target='_blank'>";
the_author_meta('user_url', $author->ID);
echo "</a>";
echo "<br />";
echo "Twitter: <a href="http://twitter.com/";
the_author_meta('twitter', $author->ID);
echo "" target='_blank'>";
the_author_meta('twitter', $author->ID);
echo "</a>";
echo "<br />";
echo "<a href="".get_bloginfo('url')."/author/";
the_author_meta('user_nicename', $author->ID);
echo "/">Visita il Profilo di ";
the_author_meta('display_name', $author->ID);
echo "</a>";
echo "</div>";
echo "</li>";
}
}
but still does the trick ….. Please help me to find out the error and its rectification. Thanks a lot.
I have modified WP_LIST_AUTHORS to paginate. I don’t know if its very sexy, and seems to require some sort of Caching plugin otherwise this particular page can start to load pretty slowly.
The full code of my paginated function is in this thread: Modifying WP_LIST_AUTHOR Functions to output all users in a grid (and Paginate)
If you just want to look directly at the pagination code I used you can go here: http://www.phpfreaks.com/tutorial/basic-pagination
In your case you can save your time the trouble by using Members List Plugin
if I add this code as I recall it in the loop?