Wordpress has an ugly wp_head (but a pretty face)
Being a massive wordpress fan there has alway been a part of me that’s been itching to sort out how wordpress uses it’s wp_head tag.
There was a time when I’d just simply comment it out to be honest as I found it was adding a lot of code in to my site that I didn’t actually need. However, when I came to using some excellent plugins such as Joost’s Meta Robots I released I did actually need the wp_head tag.
So what was the problem?
By default wordpress adds in several extra lines of code for using things like Really Simle Discovery, Windows Live Writer and the wordpress version. Thats all fine and dandy if you use those tools or want your wordpress version on display (which to me is a bit of a security risk anyway), but want if you don’t? Functions.php to the rescue then.
In essence, the functions.php file acts a bit like a plugin; you might have had a play around with it if you’ve ever set-up a wordpress blog that uses widgets. We can use this file to change what wordpress outputs into the wp_head tag.
Here’s how
If you want to remove anything from the wordpress head you need to write in the following format between php tags as below:
<?php remove_action('wp_head', 'title of what needs removing'); ?>
So to remove the Really Simple Discovery Code add:
<?php remove_action('wp_head', 'rsd_link'); ?>
To remove the Windows Live Writer add:
<?php remove_action('wp_head', 'wlwmanifest_link'); ?>
And to remove the wordpress version add:
<?php remove_action('wp_head', 'wp_generator'); ?>
Of coure if you want to add more than one you can always put as many as you need between on set of < ?php?> tags.
Happy blogging