Skip to content

Instantly share code, notes, and snippets.

@rickrduncan
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickrduncan/3b50d9526aadae4fadac to your computer and use it in GitHub Desktop.
Save rickrduncan/3b50d9526aadae4fadac to your computer and use it in GitHub Desktop.
2 Step process to remove RSS feeds from WordPress websites
<?php
//* Do NOT include the opening php tag
//* BEGIN: Disable WordPress RSS Feed
function b3m_disable_rss_feed() {
wp_die( __( 'Our RSS feed is disabled. Please <a href="/">visit our homepage</a>.' ) );
}
add_action( 'do_feed', 'b3m_disable_rss_feed', 1 );
add_action( 'do_feed_rdf', 'b3m_disable_rss_feed', 1 );
add_action( 'do_feed_rss', 'b3m_disable_rss_feed', 1 );
add_action( 'do_feed_rss2', 'b3m_disable_rss_feed', 1 );
add_action( 'do_feed_atom', 'b3m_disable_rss_feed', 1 );
//* END: Disable WordPress RSS Feed
<?php
//* Do NOT include the opening php tag
/**
* @purpose: Remove references to feed from <head> section of website
*
* @author: Rick R. Duncan
* @contact: www.rickrduncan.com
*
*/
function b3m_remove_head_links() {
remove_action( 'wp_head', 'wp_generator' ); //* Remove WP Version number
remove_action( 'wp_head', 'wlwmanifest_link' ); //* Remove wlwmanifest_link
remove_action( 'wp_head', 'rsd_link'); //* Remove rsd_link
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); //* Remove shortlink
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); //* Remove previous/next post links
remove_action( 'wp_head', 'feed_links_extra', 3 ); //* Display the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); //* Display the links to the general feeds: Post and Comment Feed
}
add_action('init', 'b3m_remove_head_links');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment