Wordpress Remove Rss Feed in Header
WordPress Disable RSS Feed
WordPress is primarily known by people for its powerful blogging features. RSS Feeds are used by people to subscribe to your new content that you post and also to feed into third-party reader applications such as Feedly. This way they can read your fresh content on the go. However, not everyone uses the blogging portion of WordPress and for some businesses, in fact, might simply want to in WordPress disable RSS feeds altogether. This is then one less thing they have to worry about.
By default WordPress generates all kinds of RSS feeds that are built in, such as:
http://example.com/feed/ http://example.com/feed/rss/ http://example.com/feed/rss2/ http://example.com/feed/rdf/ http://example.com/feed/atom/
It also generates them for your categories, tags, comments, etc.
WordPress Disable RSS Feed
There are a couple different ways to disable RSS feeds in WordPress. You can do it with a plugin or with code.
- Disable RSS Feed with Plugin
- Disable RSS Feed with Code
1. Disable RSS Feed with Plugin
The first way to disable a WordPress RSS feed is to use a free plugin like Disable Feeds. This plugin disables all RSS/Atom feeds on your WordPress website by redirecting all the requests. It also disables BuddyPress group feeds and bbPress forum feeds. It was actually created by the same developer that made the Disable Comments plugin as discussed in our other article. It is actively maintained and currently has over 20,000 active installs with a 4.9 out of 5 rating.
You can download Disable Feeds from the WordPress repository or by searching for it within your WordPress dashboard under "Add New" plugins. You can then change the settings under the "Reading" section in settings. By default, the plugin will redirect the request to its corresponding HTML content. For example, if a visitor hits a category RSS feed they will be directed to the category archive page. You can also choose to simply show a 404 error instead and whether or not to disable the global post feed and global comment feed.
Note: The plugin only disables the feeds themselves, you will still need to remove the links to your RSS feeds yourself within your WordPress theme or corresponding sidebar and footer widgets.
You could also use a premium plugin like perfmatters (developed by a team member at Kinsta), which allows you to both disable RSS feeds and disable RSS feed links, along with other optimizations for your WordPress site.
2. Disable RSS Feed with Code
The second method to disable a WordPress RSS feed is to simply use code.
Important! Editing the source code of a WordPress theme could break your site if not done correctly. If you are not comfortable doing this, please check with a developer first.
Before you get started, create a backup and use a child theme, so you won't lose your changes if you update your theme. Then, copy the following code into your child theme's functions.php file.
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);
Now if a person visits an RSS feed on your site, domain.com/feed for example, they will see the following message.
WordPress also generates links to the RSS feeds within your webpage's header, as seen in the screen below. You can go one step further and remove these links from within your pages HTML code.
Copy the following code into your functions.php file to remove the header links to your RSS feeds.
remove_action( 'wp_head', 'feed_links_extra', 3 ); remove_action( 'wp_head', 'feed_links', 2 );
Save time, costs and maximize site performance with:
- Instant help from WordPress hosting experts, 24/7.
- Cloudflare Enterprise integration.
- Global audience reach with 35 data centers worldwide.
- Optimization with our built-in Application Performance Monitoring.
All of that and much more, in one plan with no long-term contracts, assisted migrations, and a 30-day-money-back-guarantee. Check out our plans or talk to sales to find the plan that's right for you.
Source: https://kinsta.com/knowledgebase/wordpress-disable-rss-feed/
0 Response to "Wordpress Remove Rss Feed in Header"
Postar um comentário