Forums

How display top 5 authors by month and category (2 posts)

  1. microtag
    Member
    Posted 2 years ago #

    Hi.
    Code below display top authors, is possbile change and display display top 5 authors by current month and particular category?
    Could you help me?
    Thanks

    <?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;
          }
        }
      }
    }
    ?>
  2. microtag
    Member
    Posted 2 years ago #

    Nobody :(

Topic Closed

This topic has been closed to new replies.

About this Topic