Skip to content

Instantly share code, notes, and snippets.

@rickrduncan rickrduncan/step_1.php
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.