加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 创业 > 正文

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

发布时间:2018-09-13 11:17:03 所属栏目:创业 来源:站长网
导读:在 WordPress 博客上,显示每个留言者的留言总数,效果如下: 方法很简单,在funtions.php文件里加上下面的代码: function commentCountAuthor(){ $oneText = 'One comment'; $moreText = '% comments'; global $wpdb; $result = $wpdb-get_var(' SELECT

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();

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读