April 5, 2014 / IST / How-to Guides, Web Development.

If you have very extreme author in your wordpress blog than this solution will solve your problem. I saw a problem that everybody want to display author list with page navigation. WordPress has a function get_users(). This function helps you to fetch all user by role. If you pass editor than it will return all editors. If you pass author than it will return all authors. This function behaves same for contributors and subscribers.

Since this function also accept offset and number, so I will play on this arguments.

wordpress-author-page-navigation

Example:

Suppose  we want to display 10 user per page then number will be always 10. Now consider we are in the first page then offset will be 0. If we are in the second page than offset will be 10.  Because we have already displayed first 10 user in the first page.

For page navigation we use paginate_links() inbuilt wordpress function.

Take first block of program:

<?php
	$total_user = count_users();
	$per_page_user = 10;
	$total =  ceil(($total_user['avail_roles']['author'])/$per_page_user); 
	$paged = max( 1, get_query_var('paged') );
	$offset = (!isset($paged))? 0 :($paged - 1)*$per_page_user; 
	$blogusers = get_users("blog_id=1&orderby=display_name&order=ASC&role=author&offset=$offset&number=$per_page_user"); 
?>

 count_users() function returns total user with role so we have to extract only total user of authors. $total_user [‘avail_roles’][‘author’]  returns total no of users of author. It will be helpful to calculate page navigation.

$paged variable is used to hold current page information.

$offset variable is used to hold current offset.

$blogusers array object contains all authors user information.

<?php 
	foreach ($blogusers as $user) { 
	$user_id = $user->ID; 
?>
	<tr> 
		<td ><?php echo $user_id; ?></td> 
		<td ><?php echo $user->display_name; ?></td> 
		<td ><?php echo $user->user_email; ?></td> 
		<td><?php echo count_user_posts($user_id); ?></td>
		<td><a href="<?php echo get_author_posts_url($user_id);?>">View Posts</a></td> 
       </tr>
<?php } ?>

Now display page navigation:

<?php 
	echo '<div class="navigation">'; 
	$big = 999999999; // need an unlikely integer 
	echo paginate_links( array( 
		'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 
		'format' => '?paged=%#%', 
		'current' => max( 1, $paged ), 
		'total' => $total 
	) ); 
	echo '</div>'; 
?>

Whole code is:

<?php
/*
Template Name: Authors
 */

		$result = count_users();
		$per_page_user = 10;
		$total =  ceil(($result['avail_roles']['author'])/$per_page_user); 
		$paged = max( 1, get_query_var('paged') );
		$offset = (!isset($paged))? 0 :($paged - 1)*$per_page_user; 
		$blogusers = get_users("blog_id=1&orderby=display_name&order=ASC&role=author&offset=$offset&number=$per_page_user"); 
?>
	<table border="1" cellpadding="5"> 
		<tr bgcolor="#cdcdcd"> 
			<td >ID</td> 
			<td >Author Name</td> 
			<td >Author Email</td> 
			<td >Total Post</td>
			<td ></td> 
		</tr> 
		<?php 
			foreach ($blogusers as $user) { 
			$user_id = $user->ID; 
		?>
			<tr> 
				<td ><?php echo $user_id; ?></td> 
				<td ><?php echo $user->display_name; ?></td> 
				<td ><?php echo $user->user_email; ?></td> 
				<td><?php echo count_user_posts($user_id); ?></td>
				<td><a href="<?php echo get_author_posts_url($user_id);?>">View Posts</a></td> 
			 </tr>
		<?php } ?>
	</table> 
	<?php 
	echo '<div class="navigation">'; 
	$big = 999999999; // need an unlikely integer 
	echo paginate_links( array( 
		'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 
		'format' => '?paged=%#%', 
		'current' => max( 1, $paged ), 
		'total' => $total 
	) ); 
	echo '</div>'; 
	?>

Set Template Name: Authors and save it as php file into . Decorate this file according to your template. Use get_header(), get_footer() etc.