Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Paste Description for WordPress display top 10 authors

http://wordpress.org/support/topic/323053

WordPress display top 10 authors
Tuesday, October 20th, 2009 at 1:03:52pm MDT 

  1. <?php
  2. //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
  3. $uc=array();
  4. $blogusers = get_users_of_blog();
  5. if ($blogusers) {
  6.   foreach ($blogusers as $bloguser) {
  7.     $post_count = get_usernumposts($bloguser->user_id);
  8.     $uc[$bloguser->user_id]=$post_count;
  9.   }
  10.   arsort($uc); //use asort($uc) if ascending by post count is desired
  11.   $maxauthor=2;
  12.   $count=0;
  13.   foreach ($uc as $key => $value) {
  14.   $count++;
  15.     if ($count <= $maxauthor) {
  16.       $user = get_userdata($key);
  17.       $author_posts_url = get_author_posts_url($key);
  18.       $post_count = $value;
  19.       echo 'User ID ' . $user->ID . ' ' . $user->user_firstname . ' ' . $user->user_lastname . ' number of posts: ' . $post_count . ' author posts url: ' . $author_posts_url .'';
  20.       $args=array(
  21.         'showposts'=>1,
  22.         'author'=>$user->ID,
  23.         'caller_get_posts'=>1
  24.       );
  25.       $my_query = new WP_Query($args);
  26.       if( $my_query->have_posts() ) {
  27.         while ($my_query->have_posts()) : $my_query->the_post(); ?>
  28.           <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>
  29.           <?php
  30.         endwhile;
  31.       }
  32.     }
  33.   }
  34. }
  35. ?>

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

fantasy-obligation