I believe that wp_list_authors
will do what you want, sort of. You could run the function with the echo
parameter false and count the results.
$authors = wp_list_authors(
array(
'echo'=>false,
'html'=>false
)
);
echo var_dump($authors);
echo count (explode(',',$authors));
Or, alternately, and perhaps less profligately, steal that function’s SQL
.
$authors = $wpdb->get_results(
"SELECT DISTINCT post_author, COUNT(ID) AS count
FROM $wpdb->posts
WHERE post_type="post"
AND " . get_private_posts_cap_sql( 'post' ) . "
GROUP BY post_author"
);
var_dump($authors);
echo count($authors);
Those are slightly different in that the first ignores the admin user by default, but there is a parameter to change that.