You can use the get_comments()
function like so:
$total = get_comments( array(
'post_author' => get_current_user_id(),
'post_status' => 'publish',
'type' => 'comment',
'count' => true,
) );
echo 'total comments of your all posts : ' . $total;
Just customize the arguments based on your requirements/preferences, and in the above example, I’m retrieving the total number of comments for published posts where the author is the currently logged-in user, but only for comments of the comment
type.
And if you want, you can use the status
argument to limit to certain status only, e.g. approve
to count approved comments only.