How to Disable RSS Feeds in WordPress

How to Disable RSS Feeds in WordPress
645 Views
0
(0)

What exactly is RSS?

In the beginning, online surfers saved their favorite websites in their web browsers. Manually visit the websites on a regular basis to check for changes. RSS is an abbreviation for “Really Simple Syndication.”

Before you begin, make a backup and use a child theme to ensure that you don’t lose your modifications if you update your theme. Then, paste the following code into the functions.php file of your child theme.

WordPress creates all types of RSS feeds by default, including

http://example.com/feed/
http://example.com/feed/rss/

There are two ways to disable an RSS feed using plugins or custom codes. You can use many free plugins to disable RSS feeds. But let’s disable RSS feeds using code. Add the below code to your functions.php file (this file is located in your theme folder):

<?php
/* For disable rss feed url*/
function cxc_disable_feed_callback() {
	wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );
}

add_action('do_feed', 'cxc_disable_feed_callback', 1);
add_action('do_feed_rdf', 'cxc_disable_feed_callback', 1);
add_action('do_feed_rss', 'cxc_disable_feed_callback', 1);
add_action('do_feed_rss2', 'cxc_disable_feed_callback', 1);
add_action('do_feed_atom', 'cxc_disable_feed_callback', 1);
add_action('do_feed_rss2_comments', 'cxc_disable_feed_callback', 1);
add_action('do_feed_atom_comments', 'cxc_disable_feed_callback', 1);

/* For remove rss feed urls */
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
?>

Why turn off the RSS feed?

While the RSS Feed does not harm your website in any way, it may be beneficial. With that stated, social media networks such as Facebook are becoming the primary means by which visitors exchange material.

Almost every website has a social media account on Facebook, Twitter, or Instagram that informs all of its visitors that new material has been uploaded. This completely negates the RSS feed’s use, and since there are no advantages or uses for the functionality, why preserve it?

Keep in mind that even if you do not utilize social media platforms, the RSS feed may be quite beneficial to your website. This is also true if you do not have a large number of followers on your social media platforms.

How useful was this blog?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this blog.

Leave a comment

Your email address will not be published. Required fields are marked *