Created
January 8, 2025 03:40
-
-
Save faisalahammad/9852331e77c8e1e2059d274e24a5a7bd to your computer and use it in GitHub Desktop.
This code snippet disables all feed types in WordPress (RSS, Atom, RDF) and displays a custom message directing users to the homepage. Ideal for sites that do not want to offer feed capabilities.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpb_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