Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save carlitoescobar/1227bf9e76aa0e2840d8963761a16a5e to your computer and use it in GitHub Desktop.
Save carlitoescobar/1227bf9e76aa0e2840d8963761a16a5e to your computer and use it in GitHub Desktop.
WordPress loads a bunch of things via the wp_head() hook into the header of the WordPress themes. Some of them are very useful, some aren’t. Some just inflate the website unnecessarily. Here’s a small snippet to do some major cleaning up.
<?php
/**
* Frees the header from unnecessary entries
*/
add_action('init', 'evolution_remheadlink');
function evolution_remheadlink()
{
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
remove_action('wp_head', 'wp_shortlink_header', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment