Support » Fixing WordPress » List authors by posts?

  • I want to list authors by the amount of posts they made, is this possible? I couldnt see a way to do it in the docs

Viewing 5 replies - 1 through 5 (of 5 total)
  • Don’t know how efficient this is:

    //Get users and count of posts put into array $uc, sort array by post count descending, loop through array and echo user info
    $blogusers = get_users_of_blog();
    if ($blogusers) {
      foreach ($blogusers as $bloguser) {
        $post_count = get_usernumposts($bloguser->user_id);
      arsort($uc); //use asort($uc) if ascending by post count is desired
      foreach ($uc as $key => $value) {
        $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 .'';

    [Edit – note that it is descending using arsort]

    couldnt get that to work, does anyone else have any other thoughts?

    MichaelH you’re a life saver!! The code above works GREAT!! I’ve been searching for a way to do this for hours. Have you figured out by any chance if the code is efficient? Are there many db queries taking place? (I have no idea, just asking). Again, many thanks.

    igneous, give it another try. Just copy paste it into your code and then change the echo line to show the user info! You can use this list to get the user information (name, url, etc) you need.

    Hi MichaelH
    Forgive my English
    The code works for me, but I need only show 10 or 15 authors by the amount of post they made.
    How can I restrict that the code only show me 10 or 15 authors ordered by $post_count?


    Looks ok to me..
    Average time, 100 iterations (just to benchmark)..


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘List authors by posts?’ is closed to new replies.