0

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.

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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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