When looking at a the source code of WordPress themes and templates the head tag tends to be bloated with a ridiculous number meta, link and javascript tags. Depending on your situation, some of these aren’t actually needed.
When looking at a the source code of WordPress themes and templates the head tag tends to be bloated with a ridiculous number meta, link and javascript tags. Depending on your situation, some of these aren’t actually needed.
The wp_head function of WordPress contributes to this, calling in a whole bunch of largely unnecessary things such as a generator tag, letting everyone know that you’re using WordPress and what version.
This isn’t great, especially if you haven’t upgraded to the latest version, leaving you open for exploits.
Here is some code that you add to your functions.php that will remove most of the unwanted code.
add_action('init', 'clear_wp_head');
function clear_wp_head() {
remove_action( 'wp_head', 'feed_links_extra', 3 ); // Removes links to the extra feeds
remove_action( 'wp_head', 'feed_links', 2 ); // Removes links to Post and Comment feeds
remove_action( 'wp_head', 'rsd_link'); // Removes link to the Really Simple Discovery service endpoint.
remove_action( 'wp_head', 'wlwmanifest_link'); // Removes the link to the Windows Live Writer file.
remove_action( 'wp_head', 'index_rel_link'); // Removes index page link.
remove_action( 'wp_head', 'parent_post_rel_link'); // Removes prev link.
remove_action( 'wp_head', 'start_post_rel_link'); // Removes start link.
remove_action( 'wp_head', 'adjacent_posts_rel_link'); // Removes the relational links for the posts adjacent to the current post.
remove_action( 'wp_head', 'wp_generator'); // Removes the WordPress version generator meta tag.
}