I have listed all the user of a role using the following code.
<?php
$roles = array('administrator', 'editor', 'author', 'contributor', 'subscriber', 'student', 'staff');
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$args = array( 'posts_per_page' => 2, 'paged' => $paged );
$loop = new WP_Query($args);
//print_r($loop);
/* Loop through users to search for the admin and editor users. */
//while ($loop) {
foreach( $roles as $role )
{
// all users with admin or editor role
if($role == 'student')
{
$this_role = "'[[:<:]]".$role."[[:>:]]'";
$query = "SELECT * FROM $wpdb->users WHERE ID = ANY (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value RLIKE $this_role) ORDER BY user_nicename ASC LIMIT 10000";
$users_of_this_role = $wpdb->get_results($query);
if ($users_of_this_role)
{
foreach($users_of_this_role as $user)
{
//while ($loop) {
global $user_url;
$curuser = get_userdata($user->ID);
$author_post_url=get_author_posts_url($curuser->ID, $curuser->nicename);
echo "<div class='post'>";
echo "<a href='wp-admin/profile.php?user_id=$user->ID' title='.$curuser->display_name.'>";
echo "<h2>$curuser->display_name</h2>";
echo '</a>';
echo "<a href='.$user_url.' title='.$curuser->display_name'>";
echo get_avatar($curuser->user_email, '80', $avatar);
echo '</a>';
echo '<p>'.$curuser->description.'</p>';
echo '</div>';
//}
}}
}
}
//}
?>
I have installed the wp_pagenavi plugin for pagination. This plugin works fine on posts.
I want the pagination on the list users page using the wp_pagenavi plugin.
How will I do this?
Or any other plugin who will paginate my list users page?