Count number of posts by author in a category

You could do this by creating a custom WP_Query and then counting it.

$args = array( 
   'author' => 1,
   'cat'    => 5,
);

$my_query = new WP_Query( $args );
$my_count = $my_query->post_count;

Just change 1 and 5 to the Author ID and Category ID respectively.

Alternatively you can use the category slug or author’s nice name (NOT name!) as well:

$args = array(
   'author_name'   => 'bob',
   'category_name' => 'editorial',
};

Leave a Comment