1

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:

enter image description here

Anyone know what I'm doing wrong?

David.

1

2 Answers 2

0

Add 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 );
1
  • 1
    That's actually the first one I tried. Same issue. Commented Mar 18, 2022 at 13:22
0

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.

1
  • A 302 redirect to the home page is not a good choice, it would be better to send 404.
    – 8ctopus
    Commented Jun 20, 2023 at 10:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.