Skip to content

Instantly share code, notes, and snippets.

@onecooltaco
Last active September 12, 2023 19:22
Show Gist options
  • Save onecooltaco/91889570ee10b21babe4c4d5da8bf31e to your computer and use it in GitHub Desktop.
Save onecooltaco/91889570ee10b21babe4c4d5da8bf31e to your computer and use it in GitHub Desktop.
WordPress mu plugin to disable RSS feeds in WordPress
<?php
/***
Plugin Name: disable RSS feeds
Plugin URI: https://gist.github.com/onecooltaco/91889570ee10b21babe4c4d5da8bf31e
Description: Disable RSS feeds in WordPress
Version: 1.0.0
Author: Jeremy Leggat
***/
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Disable RSS feeds in WordPress.
function oct_disable_feed() {
wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
}
add_action('do_feed', 'wpb_disable_feed', 1);
add_action('do_feed_rdf', 'wpb_disable_feed', 1);
add_action('do_feed_rss', 'wpb_disable_feed', 1);
add_action('do_feed_rss2', 'wpb_disable_feed', 1);
add_action('do_feed_atom', 'wpb_disable_feed', 1);
add_action('do_feed_rss2_comments', 'wpb_disable_feed', 1);
add_action('do_feed_atom_comments', 'wpb_disable_feed', 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment