【问题标题】:Exclude comments of posts in certain categories in WordPress RSS feeds在 WordPress RSS 源中排除某些类别的帖子评论
【发布时间】:2016-02-16 10:23:27
【问题描述】:

所以我可以将某个类别的帖子排除在 WordPress RSS(等)提要中显示,我的问题是我还需要阻止 cmets 显示这些帖子。

但是转到 http://www.example.com/comments/feed/ 会显示这些帖子的 cmets,这些帖子应该保持私密。

高低搜索,各种尝试,望高手帮忙!

【问题讨论】:

  • 修复了自己,改用评论父帖子的帖子类型来排除,但你可以做你想做的事,如下所示。 xxx 和 yyy 显然是虚拟值! >function custom_comment_feed_where($where) { >global $wpdb; >// 获取帖子类型 >$where .= " AND $wpdb->posts.post_type NOT IN ( >'xxx', >'yyy' >)"; >返回$哪里; >} >add_filter('comment_feed_where', 'custom_comment_feed_where');`
  • [code]function custom_comment_feed_where($where) { global $wpdb; // 获取帖子类型 $where .= " AND $wpdb->posts.post_type NOT IN ( 'xxx', 'yyy' )";返回$哪里; } add_filter('comment_feed_where', 'custom_comment_feed_where');[/code]
  • 放弃尝试格式化代码......

标签: wordpress rss comments


【解决方案1】:
function custom_comment_feed_where($where) {
    global $wpdb;
    // get the post type
    $where .= " AND $wpdb->posts.post_type NOT IN (
        'xxx',
        'yyy'
    )";
    return $where;
}

add_filter('comment_feed_where', 'custom_comment_feed_where');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-24
    • 1970-01-01
    相关资源
    最近更新 更多