ads

Type Here to Get Search Results !

ads2

How to disable FEED URLs in WordPress website , How to disable FEED URLs in WordPress website

 


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/

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.

    // Remove feed URLs from the header
function disable_feed_links() {
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);
}
add_action('init', 'disable_feed_links');
// Redirect feed requests to the original page
function redirect_feed_requests_to_original_page($query) {
if ($query->is_feed) {
global $wp;
$current_url = home_url(add_query_arg(array(), $wp->request));
$original_url = preg_replace('/\/feed(\/.*|$)/', '', $current_url);
wp_redirect($original_url, 301);
exit;
}
}
add_action('parse_query', 'redirect_feed_requests_to_original_page');



Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Top Post Ad

Below Post Ad

Slider Image 02

Ads Area