你可以试着数一数unique 评论作者电子邮件每篇帖子:
/**
* Number of unique comment author emails per post:
*
* @see http://wordpress.stackexchange.com/a/168606/26350
* @param int $pid
* @return int
*/
function get_unique_commenters_by_post_id( $post_id )
{
global $wpdb;
$sql = "SELECT COUNT(1) as uc FROM (
SELECT COUNT(1) as c FROM {$wpdb->comments}
WHERE comment_post_ID = %d
GROUP BY comment_author_email
) as t";
return $wpdb->get_var( $wpdb->prepare( $sql, $post_id ) );
}
Usage example:
echo get_unique_commenters_by_post_id( $post_id = 213 );