Thank you very much MichaelH, but I was wondering also How can I restrict that code only to show me top 10 authors ordered by $post_count?
Thank you, again
<?php
//Get users and count of posts put into array $uc, sort array by post count ascending, loop through array and echo user info, get latest post for each user and display time and title
$uc=array();
$blogusers = get_users_of_blog();
if ($blogusers) {
foreach ($blogusers as $bloguser) {
$post_count = get_usernumposts($bloguser->user_id);
$uc[$bloguser->user_id]=$post_count;
}
arsort($uc); //use asort($uc) if ascending by post count is desired
$maxauthor=2;
$count=0;
foreach ($uc as $key => $value) {
$count++;
if ($count <= $maxauthor) {
$user = get_userdata($key);
$author_posts_url = get_author_posts_url($key);
$post_count = $value;
echo 'User ID ' . $user->ID . ' ' . $user->user_firstname . ' ' . $user->user_lastname . ' number of posts: ' . $post_count . ' author posts url: ' . $author_posts_url .'';
$args=array(
'showposts'=>1,
'author'=>$user->ID,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><small><?php the_time('m.d.y') ?></small> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
}
}
}
?>
sorry, but not working for me. I copied and pasted in one post through my dashboard editor, and this is the result:
user_id); $uc[$bloguser->user_id]=$post_count; } arsort($uc); $maxauthor=10; $count=0; foreach ($uc as $key => $value) { $count++; if ($count <= $maxauthor) { $user = get_userdata($key); $author_posts_url = get_author_posts_url($key); $post_count = $value; echo ‘User ID ‘ . $user->ID . ‘ ‘ . $user->user_firstname . ‘ ‘ . $user->user_lastname . ‘ number of posts: ‘ . $post_count . ‘ author posts url: ‘ . $author_posts_url .”; $args=array( ‘showposts’=>1, ‘author’=>$user->ID, ‘caller_get_posts’=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?>
Any suggestions?
Thank you again MichaelH
Thank you very much MichaelH
The code is working fine now!!!
Is possible sort list by current month and particular category?
Thanks