Someone has asked me a question “How to Disable RSS Feed on WordPress website” so that anyone can’t see the RSS feed of the site. Instead of RSS feed, he wants to display the custom message “No feed available, please visit the "http://www.domain-name.com"
.
Open your functions.php file from current activated theme’s folders and copy paste below code at the end of the file.
1 2 3 4 5 6 7 8 9 10 11 | 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); |
After adding the above code inside in your functions.php
file, it will display the below message and link to redirect homepage.
Apart from this WordPress also generates the RSS feeds link inside your page head like the below screenshot. You can go one step further and remove these RSS feed links from your pages HTML code.
Copy the below code into your functions.php
file to remove the RSS feed links from your page.
1 2 3 4 5 | /** * Remove RSS feed links from WordPress header */ remove_action( 'wp_head', 'feed_links_extra', 3 ); remove_action( 'wp_head', 'feed_links', 2 ); |
Hope this tutorial helped you, do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: remove wordpress rss feeds, woocommerce plugin wordpress tutorial, wordpress rss feeds, wordpress tutorial, wordpress tutorial for beginner, wordpress tutorial for beginners, wordpress tutorials, wordpress tutorials for beginners, wordpress tutorils