Get total number of authors on the site

You can use the WP_User_Query class, like the example below. Each code line have an small description, that you understand, what we do.

// Get all users with role Author.
$user_query = new WP_User_Query( array( 'role' => 'Author' ) );
// Get the total number of users for the current query. I use (int) only for sanitize.
$users_count = (int) $user_query->get_total();
// Echo a string and the value
echo 'So much authors: ' . $users_count;

Alternative you can also use the function get_users(). But is only a wrapper for the query and have much more fields in the result.

Leave a Comment