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

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

发布时间:2018-09-13 04:24:01 所属栏目:创业 来源:站长网
导读:在 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();

(编辑:湖南网)

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

    热点阅读