admin管理员组文章数量:1203386
There are loads of articles out there on how to completely disable Wordpress RSS feeds, my configuration (functions.php
) is:
function disable_feed() {
wp_die( 'You Died' , 200 );
}
add_action('do_feed', 'disable_feed', 1);
add_action('do_feed_rdf', 'disable_feed', 1);
add_action('do_feed_rss', 'disable_feed', 1);
add_action('do_feed_rss2', 'disable_feed', 1);
add_action('do_feed_atom', 'disable_feed', 1);
add_action('do_feed_rss2_comments', 'disable_feed', 1);
add_action('do_feed_atom_comments', 'disable_feed', 1);
But instead of getting a nice-looking HTML page with the bordered content normally associated with the wp_die()
function, when browsing to https://website/feed/ I'm getting this knarley page back:
Anyone know what I'm doing wrong?
David.
There are loads of articles out there on how to completely disable Wordpress RSS feeds, my configuration (functions.php
) is:
function disable_feed() {
wp_die( 'You Died' , 200 );
}
add_action('do_feed', 'disable_feed', 1);
add_action('do_feed_rdf', 'disable_feed', 1);
add_action('do_feed_rss', 'disable_feed', 1);
add_action('do_feed_rss2', 'disable_feed', 1);
add_action('do_feed_atom', 'disable_feed', 1);
add_action('do_feed_rss2_comments', 'disable_feed', 1);
add_action('do_feed_atom_comments', 'disable_feed', 1);
But instead of getting a nice-looking HTML page with the bordered content normally associated with the wp_die()
function, when browsing to https://website/feed/ I'm getting this knarley page back:
Anyone know what I'm doing wrong?
David.
Share Improve this question asked Mar 16, 2022 at 21:19 David AdamsDavid Adams 335 bronze badges 1- See wordpress.org/support/topic/… – 8ctopus Commented Jun 20, 2023 at 11:58
2 Answers
Reset to default 0Add following code to: functions.php
function itsme_disable_feed() {
wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );
}
add_action('do_feed', 'itsme_disable_feed', 1);
add_action('do_feed_rdf', 'itsme_disable_feed', 1);
add_action('do_feed_rss', 'itsme_disable_feed', 1);
add_action('do_feed_rss2', 'itsme_disable_feed', 1);
add_action('do_feed_atom', 'itsme_disable_feed', 1);
add_action('do_feed_rss2_comments', 'itsme_disable_feed', 1);
add_action('do_feed_atom_comments', 'itsme_disable_feed', 1);
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
I just couldn't get this to work. I was expecting the wp_die()
function to provide its message on a pretty HTML page, like this example: https://www.wpbeginner.com/wp-tutorials/how-to-disable-rss-feeds-in-wordpress/
...but all I get is this nasty XML tree.
I've changed my solution now to instead HTTP302 redirect the visitor to ./feed/ to the homepage. This is actually a better solution, I believe, because it means Wordpress is not run.
本文标签: functionsCompletely Disable Wordpress RSS Feeds
版权声明:本文标题:functions - Completely Disable Wordpress RSS Feeds 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738668703a2105864.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论