我想显示其他用户为作者的所有帖子提交的评论总数!例如:
get_author_posts_total_number_of_comments($author->ID);
任何想法?
答案 0 :(得分:2)
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));
}