为了使博客内容实时推送给关注的读者,大部分都采用了RSS订阅方式,
现在通过这种方式阅读的人越来越少了,还成了垃圾站快速采集的方式,
那么如何彻底移除并关闭WordPress的RSS feed。
关闭WordPress RSS feed方法:
在WordPress主题的functions.php文件至下方的“?>”前,加入以下PHP代码即可。
在WordPress中,要关闭RSS/Atom Feed,你可以使用remove_action函数从WordPress引擎中移除默认的feed输出。
以下是一个示例代码,你可以将其添加到你的主题的functions.php文件中:
这段代码将会从WordPress的头部输出中移除所有的feed链接。
如果你只想关闭特定类型的feed(如仅Atom Feed),你可以只移除feed_links_extra和相关的特定feed函数。
// 移除默认的RSS和Atom Feed remove_action('wp_head', 'wp_enqueue_scripts', 1); remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'feed_links_extra', 3); // 如果你想彻底关闭所有的feeds,还可以移除所有的feeds remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'atom_link_feed', 2); remove_action('wp_head', 'rsd_link_tag'); remove_action('wp_head', 'wlwmanifest_link_tag'); remove_action('wp_head', 'rsd_link_tag'); remove_action('wp_head', 'atom_link_feed'); remove_action('wp_head', 'feed_links_extra'); remove_action('wp_head', 'sticky_post_types'); //上面两段也可以不要 function sdczz_disable_feed() { wp_die(__('本站不再提供RSS Feed订阅服务,请返回首页'.get_bloginfo('url').'')); } add_action('do_feed', 'sdczz_disable_feed', 1); add_action('do_feed_rdf', 'sdczz_disable_feed', 1); add_action('do_feed_rss', 'sdczz_disable_feed', 1); add_action('do_feed_rss2', 'sdczz_disable_feed', 1); add_action('do_feed_atom', 'sdczz_disable_feed', 1);