Disable RSS Feed Pages in WordPress

To disable RSS feed pages in WordPress, hook into the action filters provided for each feed page function and then redirect to the home page.

// Disable RSS feed pages
add_action( 'do_feed', 'disable_rss_feed_pages', 1);
add_action( 'do_feed_rdf', 'disable_rss_feed_pages', 1);
add_action( 'do_feed_rss', 'disable_rss_feed_pages', 1);
add_action( 'do_feed_rss2', 'disable_rss_feed_pages', 1);
add_action( 'do_feed_atom', 'disable_rss_feed_pages', 1);
add_action( 'do_feed_rss2_comments', 'disable_rss_feed_pages', 1);
add_action( 'do_feed_atom_comments', 'disable_rss_feed_pages', 1);

function disable_rss_feed_pages() {
    wp_redirect( site_url() );
    exit();
}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *