Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This is a listing of members with pagination

<?php
$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):
shuffle($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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.