Modifying WP_LIST_AUTHOR Functions to output all users in a grid (and Paginate)

Your snippet is a little too verbose to follow (and it’s late here) so this is more of an alternate take. I think that forking wp_list_author() might be overkill here. It would be more elegant to hook inside user search and accurately slice the portion of authors you need.

Here is some example code I came up with:

add_action('pre_user_query','offset_authors');

$authors_per_page = 1;
$current_page = absint(get_query_var('page'));

function offset_authors( $query ) {

    global $current_page, $authors_per_page;

    $offset = empty($current_page) ? 0 : ($current_page - 1) * $authors_per_page;    
    $query->query_limit = "LIMIT {$offset},{$authors_per_page}";
}

wp_list_authors();

Also check out paginate_links() function for building pagination.

Leave a Comment