之前写的WordPress禁用RSS Feed方法已经比较老了,现在更新一下如何在 WordPress 中禁用 RSS 源的最新方法。
使用插件禁用 RSS 源
您需要做的第一件事是安装并激活 Disable Feeds 插件。
在 WordPress 中手动禁用 RSS 源
在WordPress主题文件functions.php
中或者使用Code Snippets插件添加自定义代码:
function wpb_disable_feed() { wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'" rel="nofollow">homepage</a>!') ); } add_action('do_feed', 'wpb_disable_feed', 1); add_action('do_feed_rdf', 'wpb_disable_feed', 1); add_action('do_feed_rss', 'wpb_disable_feed', 1); add_action('do_feed_rss2', 'wpb_disable_feed', 1); add_action('do_feed_atom', 'wpb_disable_feed', 1); add_action('do_feed_rss2_comments', 'wpb_disable_feed', 1); add_action('do_feed_atom_comments', 'wpb_disable_feed', 1); remove_action('wp_head', 'feed_links_extra', 3); remove_action('wp_head', 'feed_links', 2);