WordPress is one of the best Content Management System (CMS) available. There will be times that you will create a static website and does not want to implement RSS Feeds. But that feature is automatically included in WordPress and in order to turn it off, you would have to edit core files. But in this article we will show you how you can disable RSS Feeds without editing the core file by simply creating a function in WordPress.
Open your functions.php located within your themes folder and add the following code:
01 | function fb_disable_feed() { |
02 | wp_die( __( 'No feed available,please visit our <a href="' . get_bloginfo( 'url' ) . '">homepage</a>!' ) ); |
05 | add_action( 'do_feed' , 'fb_disable_feed' , 1); |
06 | add_action( 'do_feed_rdf' , 'fb_disable_feed' , 1); |
07 | add_action( 'do_feed_rss' , 'fb_disable_feed' , 1); |
08 | add_action( 'do_feed_rss2' , 'fb_disable_feed' , 1); |
09 | add_action( 'do_feed_atom' , 'fb_disable_feed' , 1); |
10 | add_action( 'do_feed_rss2_comments' , 'fb_disable_feed' , 1); |
11 | add_action( 'do_feed_atom_comments' , 'fb_disable_feed' , 1); |
Once you add this code, anytime someone tries to reach your feeds, they will see this message: “No feed available, please visit our homepage.” You can change the message to fit your needs.