Title: 2famous's Replies | WordPress.org

---

# 2famous

  [  ](https://wordpress.org/support/users/2famous/)

 *   [Profile](https://wordpress.org/support/users/2famous/)
 *   [Topics Started](https://wordpress.org/support/users/2famous/topics/)
 *   [Replies Created](https://wordpress.org/support/users/2famous/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/2famous/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/2famous/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/2famous/engagements/)
 *   [Favorites](https://wordpress.org/support/users/2famous/favorites/)

 Search replies:

## Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [List categories by author ~ WITH COUNTER ~](https://wordpress.org/support/topic/list-categories-by-author-with-counter/)
 *  Thread Starter [2famous](https://wordpress.org/support/users/2famous/)
 * (@2famous)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/list-categories-by-author-with-counter/#post-3892807)
 * I figured it out… had to run to separate SELECT functions: one to fetch the list
   of categories, and then one more functions within that loop to count how many
   entries there is within the category. I would have preferred to have these two
   loops as one, but this works out for me.
 *     ```
       <?php
   
       // This will get us a list of the categories that our Author has published in
       $author = get_query_var('author');
       $categories = $wpdb->get_results("
   
       SELECT DISTINCT(terms.term_id) as ID, terms.name, terms.slug, tax.description
       FROM $wpdb->posts as posts
       LEFT JOIN $wpdb->term_relationships as relationships ON posts.ID = relationships.object_ID
       LEFT JOIN $wpdb->term_taxonomy as tax ON relationships.term_taxonomy_id = tax.term_taxonomy_id
       LEFT JOIN $wpdb->terms as terms ON tax.term_id = terms.term_id
       WHERE posts.post_status = 'publish' AND
           posts.post_author = '$author' AND
           tax.taxonomy = 'category'
       ORDER BY terms.name ASC
       ");
   
       // This loop picks up categories
       foreach($categories as $category) : 
   
       $catid = $category->ID;
   
       // Now, inside the loop, we need to count how many posts that the Author has published.
       $counter = "SELECT COUNT(*)
       FROM $wpdb->posts
       LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
       LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
       WHERE $wpdb->term_taxonomy.term_id = $catid
       AND $wpdb->term_taxonomy.taxonomy = 'category'
       AND $wpdb->posts.post_status = 'publish'
       AND post_author = '$author'
       ";
   
       $user_count = $wpdb->get_var($counter);
   
       echo '<div class="archive_author">' . $category->name . '<br/><span class="subcounter">' . $user_count . ' posts</span></div>';
   
       endforeach; 
   
       ?>
       ```
   
 * Thanks
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [List categories by author ~ WITH COUNTER ~](https://wordpress.org/support/topic/list-categories-by-author-with-counter/)
 *  Thread Starter [2famous](https://wordpress.org/support/users/2famous/)
 * (@2famous)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/list-categories-by-author-with-counter/#post-3892640)
 * This code counts the posts in the category, and works fine. I want to combine
   this with the code above, but I don’t know how to do it…
 *     ```
       <?php
           $counter = "SELECT COUNT(*)
           FROM $wpdb->posts
           LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
           LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
           WHERE $wpdb->term_taxonomy.term_id = 412
           AND $wpdb->term_taxonomy.taxonomy = 'category'
           AND $wpdb->posts.post_status = 'publish'
           AND post_author = '1'
           ";
   
           $user_count = $wpdb->get_var($counter);
   
           echo $user_count;
   
           ?>
       ```
   
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to allow visitors to subscribe to multiple authors?](https://wordpress.org/support/topic/how-to-allow-visitors-to-subscribe-to-multiple-authors/)
 *  [2famous](https://wordpress.org/support/users/2famous/)
 * (@2famous)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/how-to-allow-visitors-to-subscribe-to-multiple-authors/#post-2735956)
 * Yeah… anyone that knows? I totally need that, but there doesn’t seem to be any
   plugins out there to manage this?

Viewing 3 replies - 1 through 3 (of 3 total)