Blog

The Haycroft Media Blog covers all aspects of website design and development from the web browsers being used through to the standards that govern the world wide web. As a website design and development company, it is imperative that we keep abreast of all the latest news and happenings in our field, and here we present the major stories along with tutorials, tips and other web-programming related items.

Strip wp_head in WordPress

The wp_head() call in the header of most themes is an invitation for WordPress to start inserting code into your nice tidy head.

However, we are of the opinon that if you don’t need it, get rid of it. If you view the source of this site, you will see that we have removed the rsd link, the wml manifest link and the generator link. We’re not using them, so we don’t need them.

In addition, many WordPress security blogs recommend removing the generator tag as it reveals the version of WordPress you are using. So, say the good people at WordPress discover a major security flaw in version 2.6 and you haven’t upgraded to 2.7 yet, anyone with a knowledge of the flaw knows that your site is vulnerable.

So, how do we remove these pesky tags? Simply add the following to your themes functions.php file:

function striphead() {
	remove_action('wp_head', 'rsd_link');
	remove_action('wp_head', 'wlwmanifest_link');
	add_filter('the_generator', 'no_generator');
}
function no_generator() {
	return '';
}
add_action('init', 'striphead');
[ Back ]
Posted on Tuesday, December 1st, 2009, Filed under php, wordpress