WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] List of top 10 authors in the blog with some (8 posts)

  1. pfernandezm59
    Member
    Posted 4 years ago #

    I'm a neewbe in wordpress and I would like to know how can I display a list of TOP 10 authors in my blog with this format?:

    1. [Author name] [xx posts] [Last Post Title] [Date of last post title]
    1. [Author name] [xx posts] [Last Post Title] [Date of last post title]
    1. [Author name] [xx posts] [Last Post Title] [Date of last post title]
    1. [Author name] [xx posts] [Last Post Title] [Date of last post title]
    1. [Author name] [xx posts] [Last Post Title] [Date of last post title]
    1. [Author name] [xx posts] [Last Post Title] [Date of last post title]
    1. [Author name] [xx posts] [Last Post Title] [Date of last post title]

    I'm using wordpress 2.8.4, with Brandford's Magazine Theme (www.wp-themes.der-prinz.com/magazine) for a spanish basketball blog that's now under construction (www.cbgranollers.com).
    Thank you very much in advance
    Thank you very much in advance.

  2. MichaelH
    Member
    Posted 4 years ago #

  3. pfernandezm59
    Member
    Posted 4 years ago #

    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

  4. MichaelH
    Member
    Posted 4 years ago #

    <?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;
          }
        }
      }
    }
    ?>
  5. pfernandezm59
    Member
    Posted 4 years ago #

    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

  6. MichaelH
    Member
    Posted 4 years ago #

    Well it's working for me...

    http://wordpress.pastebin.ca/1633379

  7. pfernandezm59
    Member
    Posted 4 years ago #

    Thank you very much MichaelH
    The code is working fine now!!!

  8. microtag
    Member
    Posted 4 years ago #

    Is possible sort list by current month and particular category?
    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags