WordPress Version: 6.1
/**
* Retrieves the number of posts by the author of the current post.
*
* @since 1.5.0
*
* @return int The number of posts by the author.
*/
function get_the_author_posts()
{
$post = get_post();
if (!$post) {
return 0;
}
return count_user_posts($post->post_author, $post->post_type);
}