您可以使用get_comments() 功能如下:
$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;
只需自定义
arguments 根据您的要求/首选项,在上面的示例中,我将检索作者是当前登录用户的已发布帖子的评论总数,但仅针对
comment 类型
如果您愿意,可以使用status 参数仅限于某些状态,例如。approve 仅统计已批准的评论。