justjoe
justjoe

Reputation: 5564

I need to block my feed completly

I'm in need a solution via coding. on how to completely hide my blog feed. I know how to optimize related hook and filter such as 'the_excerpt_rss' and 'the_post_rss'. And also understand how to limit access or make my blog private.

So, the question is more about how to blocking feed access without make my blog private ?

I hope the solution will be not some apache .htacceess. Cause I need to code it directly into my theme..

Upvotes: 0

Views: 295

Answers (1)

markratledge
markratledge

Reputation: 17561

This should do it in functions.php without having to edit core WP files:

function fb_disable_feed() {
    wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
}

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

Also remove the feed link in your header.php

Upvotes: 3

Related Questions