Skip to content

Instantly share code, notes, and snippets.

@flexseth
Created November 3, 2021 22:23
Show Gist options
  • Save flexseth/7c2fab3928625e8a8bcdf90678050656 to your computer and use it in GitHub Desktop.
Save flexseth/7c2fab3928625e8a8bcdf90678050656 to your computer and use it in GitHub Desktop.
Disable RSS in WordPress
<?php /* Do NOT include the opening PHP tag
function itsme_disable_feed() {
wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );
}
add_action('do_feed', 'itsme_disable_feed', 1);
add_action('do_feed_rdf', 'itsme_disable_feed', 1);
add_action('do_feed_rss', 'itsme_disable_feed', 1);
add_action('do_feed_rss2', 'itsme_disable_feed', 1);
add_action('do_feed_atom', 'itsme_disable_feed', 1);
add_action('do_feed_rss2_comments', 'itsme_disable_feed', 1);
add_action('do_feed_atom_comments', 'itsme_disable_feed', 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment