Skip to content

Instantly share code, notes, and snippets.

@vdite
Created June 28, 2013 20:04
Show Gist options
  • Save vdite/5887650 to your computer and use it in GitHub Desktop.
Save vdite/5887650 to your computer and use it in GitHub Desktop.
Completely Remove RSS Feeds in WordPress
<?php
// add this to yout functions.php file
// you may just want to kill all your RSS Feeds, wordpress does provide
remove_action('do_feed', 'disable_all_feeds', 1);
remove_action('do_feed_rdf', 'disable_all_feeds', 1);
remove_action('do_feed_rss', 'disable_all_feeds', 1);
remove_action('do_feed_rss2', 'disable_all_feeds', 1);
remove_action('do_feed_atom', 'disable_all_feeds', 1);
// or you wanna kill them, but tell the readers why.
// http://www.doitwithwp.com/completely-remove-rss-feeds-in-wordpress/
function disable_all_feeds() {
wp_die( __('Sorry, our content is not available by RSS. Please head over to <a href="'. get_bloginfo('url') .'">our site</a>') );
}
add_action('do_feed', 'disable_all_feeds', 1);
add_action('do_feed_rdf', 'disable_all_feeds', 1);
add_action('do_feed_rss', 'disable_all_feeds', 1);
add_action('do_feed_rss2', 'disable_all_feeds', 1);
add_action('do_feed_atom', 'disable_all_feeds', 1);
// do not forget to cleanup the head links
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
?>
@KrashTestDumby
Copy link

// add this to yout functions.php file

Where?

  • Copied everything, pasted at the end of functions.php and got a code error on the opening <
  • Copied just the remove_action()'s and pasted to the end, nothing useful happened (but then, nothing broke, either).

I certainly appreciate your sharing with everyone, but not everyone is a seasoned veteran PHP programmer, intimately familiar with the inner workings of Wordpress. And I'm lucky I have access to my systems shell and know vim; if that hadn't been true, the error in attempt #1 would have rendered my site useless until I could get help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment