List categories by author ~ WITH COUNTER ~ (Wordpress)

前端 未结 3 805
野的像风
野的像风 2021-01-15 03:12

This is the code that I\'ve got. It gives a list of the categories a given author has published in. However, I would very much like to have a number next to the category nam

3条回答
  •  不思量自难忘°
    2021-01-15 03:45

    I usually use this plugin ( http://wordpress.org/plugins/author-profiles/ ) to display in the sidebar. And I guess this code will help any one

      base_prefix;
      $table_users.="users";
      $table_posts.=$wpdb->base_prefix;
      $table_posts.="posts";
    
    
      $fetch_authordata="SELECT count(p.post_author) as post1,c.id, c.user_login, c.display_name,c.user_nicename, c.user_email, c.user_url, c.user_registered FROM {$table_users} as c , {$table_posts} as p {$where} and p.post_type = 'post' AND p.post_status = 'publish' and c.id=p.post_author GROUP BY p.post_author order by post1 DESC limit {$author_numbers}  ";
    
      $dispaly_authordata = (array) $wpdb->get_results("{$fetch_authordata}", object);
    
    
      foreach ( $dispaly_authordata as $author ) {
      $user = get_userdata($author->id);
    
      echo 'Display Name: '.$user->display_name;
      echo 'Post Count: '.$post_count = get_usernumposts($user->ID);
    
      }
     ?>
    

提交回复
热议问题