Remove extra header tags

WordPress generates a handful of <meta> tags that are not always used by a theme, so here’s a trick to remove some or all of them:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
* code #5 - removes excess WordPress header tags from default themes.
* feel free to customize the options to suit your own needs.
*/
function clean_wp_header() {
    remove_action('wp_head', 'wp_generator');
    remove_action('wp_head', 'rel_canonical');
    remove_action('wp_head', 'rsd_link');
    remove_action('wp_head', 'feed_links',2);
    remove_action('wp_head', 'feed_links_extra',3);
    remove_action('wp_head', 'wlwmanifest_link');
    remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
    remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
}
add_action('init', 'clean_wp_header');

There’s more of it in this collection.