How disable feeds in WordPress without plugin. Redirect and ... open

How disable feeds in WordPress without plugin. Redirect and remove from code

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators

RSS feeds have both advantages and disadvantages.

Pros of RSS

It is possible to subscribe and read your feeds, this may have a positive impact on the attendance of your site (rarely).

Cons of RSS

The content of your site can be stolen and used on another resource.

Garbage (duplicate) pages of your site are created in the search results.

But for most regular users, this feature is not needed at all. So let’s turn off RSS feeds on WordPress.

Add this code in your theme function.php file:

//disable feeds and redirect him to homepage
function disable_feeds() {
	wp_redirect( home_url(), 302 );
exit;
}

add_action('do_feed', 'disable_feeds', 1);
add_action('do_feed_rdf', 'disable_feeds', 1);
add_action('do_feed_rss', 'disable_feeds', 1);
add_action('do_feed_rss2', 'disable_feeds', 1);
add_action('do_feed_atom', 'disable_feeds', 1);

Now you need to remove their code from our HTML template. Also add this code to yours function.php file:

//delate feeds html links
function disable_feeds_htlm(){
	remove_action( 'wp_head', 'feed_links', 2 );
	remove_action( 'wp_head', 'feed_links_extra', 3 );
}
add_action( 'wp_head', 'disable_feeds_htlm', 1 );
0

More

Leave a Reply

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

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation