WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a listing of members with pagination

$total = "SELECT ID, user_nicename from $wpdb->users ORDER BY user_nicename DESC";

$totalposts = $wpdb->get_results($total, OBJECT);

$ppp = intval(get_query_var('posts_per_page'));

$wp_query->found_posts = count($totalposts);

$wp_query->max_num_pages = ceil($wp_query->found_posts / $ppp);

$on_page = intval(get_query_var('paged'));

if($on_page == 0){ $on_page = 1; }

$offset = ($on_page-1) * $ppp;

$wp_query->request = "SELECT ID, user_nicename from $wpdb->users ORDER BY user_nicename DESC LIMIT $ppp OFFSET $offset";

$pageposts = $wpdb->get_results($wp_query->request, OBJECT);

<?php if ($pageposts):
array_rand($pageposts); ?>

<?php foreach ($pageposts as $author):
// Get user data
$curauth = get_userdata($author->ID);
// Get link to author page
$user_link = get_author_posts_url($curauth->ID);
// Set default avatar (values = default, wavatar, identicon, monsterid)
$avatar = 'wavatar';

<?php setup_postdata($post); ?> 

If I can include avatar, I think I can show post count and comment count too.

share|improve this question
Is there any particular reason you used a direct SQL statement rather than the WP_User_Query object? codex.wordpress.org/Class_Reference/WP_User_Query – Tom J Nowell Apr 12 '12 at 11:38
Also you have a zero acceptance rate, could you review your previous questions and accept any correct answers? – Tom J Nowell Apr 12 '12 at 11:39

There's the count_user_posts function which will give you a count of posts for a given user id. From a quick look through the Codex, I don't see a similar function to return a comment count. But after looking at the source for count_user_posts, I think it would be easy to adapt the code to count comments instead.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.