我在一个私人网站上工作,那里需要隐藏评论。我知道如何从标题中删除注释提要,但是谁能给我一些关于如何完全禁用注释提要的说明呢。因为你所需要做的就是在单个帖子中添加/feed/然后你就可以看到评论feed了。
我尝试创建feed-atom注释。php和feed-rss2-comments。php,但这仍然不起作用。
我在一个私人网站上工作,那里需要隐藏评论。我知道如何从标题中删除注释提要,但是谁能给我一些关于如何完全禁用注释提要的说明呢。因为你所需要做的就是在单个帖子中添加/feed/然后你就可以看到评论feed了。
我尝试创建feed-atom注释。php和feed-rss2-comments。php,但这仍然不起作用。
像这样的事情应该行得通。
function wpse45941_disable_feed( $comments ) {
if( $comments ) {
wp_die( \'No feed available\' );
}
}
add_action(\'do_feed\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_rdf\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_rss\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_rss2\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_atom\', \'wpse45941_disable_feed\',1 );
注意:我根本没有测试过,我只是把它写进了答案框。is_single()
在执行之前wp_die()
).它还使用410
error code which means GONE
而且似乎适合这个用例(至少对我来说,这些URL已经存在并被索引,我想明确地告诉谷歌和朋友们停止索引)。
function wpse45941_disable_feed( $comments ) {
if( $comments and is_single() ) {
wp_die( \'Feeds for comments on single posts have been disabled.\', 410 );
}
}
add_action(\'do_feed\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_rdf\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_rss\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_rss2\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_atom\', \'wpse45941_disable_feed\',1 );
410
HTTP状态,但它也将禁用站点范围的注释提要(并显示适当的消息):function wpse45941_disable_feed( $comments ) {
if( $comments ) {
wp_die( \'Feeds for comments have been disabled.\', 410 );
}
}
add_action(\'do_feed\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_rdf\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_rss\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_rss2\', \'wpse45941_disable_feed\',1 );
add_action(\'do_feed_atom\', \'wpse45941_disable_feed\',1 );
<item>
对于普通RSS提要中的每个帖子,在进一步检查时,我在验证我的站点的主(帖子)RSS提要时发现以下错误:RSS仍然有效,但我正在寻找一种解决方案来摆脱它。This Core Trac issue is relevant
有很多教程,但它们都提供相同的代码片段。我把它放在我的htaccess文件中,但提要没有被重定向。我不想使用插件。我确信代码是有效的。我需要弄清楚为什么它对我不起作用。以下是我的部分代码:# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\\.php$ - [L] RewriteCond %{REQUEST_FILENAM