Paginate a list of users?

As BandonRandon mentioned in the comments you can use the offset and number to query 10 users at a time.

Here’s a simplified version of what I do in my Simple User Listing plugin which lists users with built-in pagination and the ability for customizing the list output in your theme, so it might save you some trouble.

// Get Query Var for pagination. This already exists in WordPress
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;

// Calculate the offset (i.e. how many users we should skip)
$offset = ($page - 1) * $number;

// users per page
$number = 10;

$args2 =
    array(
    'offset' => $offset,
    'number' => $number,
);

$sul_users = new WP_User_Query( $args );

Leave a Comment