Wordpress has an ugly wp_head (but a pretty face)

☂ Filed under Wordpress ★ 5 comments 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

❛ 5 Comments ❜

  1. gadget

    Very useful, thanks. I agree that WP is excellent for the beginner but you have to work hard to get the best out of it and learn some basic PHP. I’m comfortable with HTML but have taught myself PHP in order to present my sites better.

  2. Freeware

    I will update my functions.php file till tonight. I was annoyed by the “wlwmanifest” (???) in the head of my page… Thank you very much for the code! Nicholas

  3. DG

    Thank you very much. I have been wanting to get rid of those lines from the source HTML of my site. I do not use the xml-rpc, remote posting type of features. I agree the “generator” is just asking for trouble, so good to remove that.

Trackbacks/Pingbacks

  1. […] Anleitung, um die wp_head-Funktion hinsichtlich ihrer Ausgaben zu beeinflussen, findet sich bei Peter Coles. Hier die kommentierte Zusammenfassung für unsere Copy-Paste-Fraktion (einfach über den […]

  2. […] Wordpress has an ugly wp_head (but a pretty face) […]

∞ Leave a reply