WordPress 显示单个留言者的留言总数

WordPress博客上,显示每个留言者的留言总数,效果如下:

WordPress 显示单个留言者的留言总数

方法很简单,在funtions.php文件里加上下面的代码:

function commentCountAuthor(){ $oneText = 'One comment';
$moreText = '% comments'; global $wpdb; $result = $wpdb->get_var('
SELECT
COUNT(comment_ID)
FROM
'.$wpdb->comments.'
WHERE
comment_author_email = "'.get_comment_author_email().'"'
); if($result == 1): echo str_replace('%', $result, $oneText); elseif($result > 1): echo str_replace('%', $result, $moreText); endif;}

然后在评论loop里调用这个函数就Ok了。

commentCountAuthor();

dawei

【声明】:嘉兴站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。