Focus on cloud service provider activities
Notes on website operation and maintenance

Forbid WordPress from being subscribed to RSS Disable FEED RSS function

Considering the privacy of information, we don't want our website to be subscribed to by other people's RSS tools. We can ban it here.

 function disable_all_feeds() { Wp_die ('This website does not provide feeds, please go directly to www.laozuo. org '); } add_action('do_feed', 'disable_all_feeds', 1); add_action('do_feed_rdf', 'disable_all_feeds', 1); add_action('do_feed_rss', 'disable_all_feeds', 1); add_action('do_feed_rss2', 'disable_all_feeds', 1); add_action('do_feed_atom', 'disable_all_feeds', 1);

We can also ban it completely through this method.

 //Forbid RSS laozuo.org add_action( 'wp_head', 'laozuoorg_wp_head', 1 ); function laozuoorg_wp_head() { remove_action( 'wp_head', 'feed_links', 2 ); remove_action( 'wp_head', 'feed_links_extra', 3 ); } foreach( array( 'rdf', 'rss', 'rss2', 'atom' ) as $feed ) { add_action( 'do_feed_' . $feed, 'banzhuti_remove_feeds', 1 ); } unset( $feed ); //Redirect to home page when do_feed action is executed function banzhuti_remove_feeds() { wp_redirect( home_url(), 302 ); exit(); } //Delete the feed redirection rule add_action( 'init', 'banzhuti_kill_feed_endpoint', 99 ); function banzhuti_kill_feed_endpoint() { global $wp_rewrite; $wp_rewrite->feeds = array(); //After running once, remember to delete the following code flush_rewrite_rules(); }

Put the above php code into the functions.php of the current topic. Of course, we can also use some plug-ins, such as the LESEO plug-in.

Vote for you
Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Forbid WordPress from being subscribed to RSS Disable FEED RSS function