Count author posts in certain category
I am using this code to only get authors who have posted in the 'Travel' category but the part 'category_name' = 'travel'
doesn't seem to work. The code currently gets all posts in all categories.
?php
$args = array(
'exclude' = array( 10, 18 ),
'role' = 'contributor',
'category_name' = 'travel',
);
$wp_user_query = new WP_User_Query($args);
$authors = $wp_user_query-get_results();
if (!empty($authors)) {
foreach ($authors as $author) {
if ( count_user_posts($author-ID) = 1 ) {
}
}
}
Topic list-authors wp-query Wordpress
Category Web