Wordpress 作者帖子的评论总数

Wordpress 作者帖子的评论总数,wordpress,Wordpress,我想显示的评论总数,其他用户提交的所有文章的作者!例如,类似这样的事情: get_author_posts_total_number_of_comments($author->ID); 有什么想法吗?这很有效:$sql=“选择$wpdb->posts WHERE post\u author=%d中的SUM(comment\u count)作为总计”;返回$wpdb->get_var($wpdb->prepare($sql,$id)),prepare函数在WP 3.5中有更改。@maior

我想显示的评论总数,其他用户提交的所有文章的作者!例如,类似这样的事情:

get_author_posts_total_number_of_comments($author->ID);

有什么想法吗?

这很有效:
$sql=“选择$wpdb->posts WHERE post\u author=%d中的SUM(comment\u count)作为总计”;返回$wpdb->get_var($wpdb->prepare($sql,$id)),prepare函数在WP 3.5中有更改。@maiorano84如何显示它?@Greenhoe您可以在您使用的任何模板中回显它。@maiorano84在编辑后继续工作,非常感谢much@Greenhoe随时直到你评论说有语法错误,我才意识到。
function get_author_posts_total_number_of_comments($authorID)
{
    global $wpdb;
    $sql = "SELECT SUM(comment_count) AS total FROM $wpdb->posts WHERE post_author=%d";
    return $wpdb->get_var($wpdb->prepare($sql,$authorID));
}