Disable RSS Feeds
Redirects every feed URL to the homepage and removes feed links from the page head. Useful for brochure sites and web apps that do not publish posts.
Opens WPIDE on
Code
$wpide_feed_redirect = function () {
wp_safe_redirect( home_url( '/' ), 301 );
exit;
};
foreach ( array( 'do_feed', 'do_feed_rdf', 'do_feed_rss', 'do_feed_rss2', 'do_feed_atom', 'do_feed_rss2_comments', 'do_feed_atom_comments' ) as $wpide_feed_hook ) {
add_action( $wpide_feed_hook, $wpide_feed_redirect, 1 );
}
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.