让WordPress不显示来自“自己”评论

日期:2008-09-06 | 作者: Allen

来自“自己”有些是作者回复评论的评论,有些是内连接引起的pingback。

下面我们要达到的目的是:让评论不显示作者的回复、不显示pingback

方法

在 wp-includes\widgets.php 文件中,找到如下代码:

SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = ’1′ ORDER BY comment_date_gmt DESC LIMIT $number

将其改为

SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = ’1′ AND user_id<>1 AND comment_type<>’pingback’  ORDER BY comment_date_gmt DESC LIMIT $number

原理

修改了获取评论的SQL语句,其中comment_type是评论的类型,除了上面用到的“pingback”还有“trackback”,如果comment_type是””,表示该评论是普通的评论。

也许你还会喜欢

3 Responses to “让WordPress不显示来自“自己”评论”

  1. 1 kinsey 二月 4th, 2010 at 2:20 上午

    用这个方法式了,结果无效。。。

    回复

    苏建报博客七月 29th, 2011 at 10:16 上午

    我想让“最新评论”那栏不要提取自己的评论 而文章中自己的评论依然在 这个功能试了 实现不了

    回复

  2. 2 远走高飞 十二月 17th, 2010 at 11:11 上午

    评论不显示作者的回复、不显示pingback这样页面更加友好~

    回复

Leave a Reply

Additional comments powered by BackType