WordPress – removing junk from “head”

By default, WordPress likes to put a number of things in the head. Sometimes, you might not want some of them though. Here’s a way to remove a few.

Note that this requires some basic knowledge when it comes to editing php. You should also back up your site first just in case something goes awry.

Before we start, I’ll assume you looked at the header.php of your theme. If you want to remove RSS feeds, often the theme includes it and it’s a simple matter of hitting Appearance/Editor, finding header.php and ditching the RSS stuff there. Be sure to refresh your site after making changes. Oh and if you update your theme in the future, that stuff might make it’s way back in, so either be ready to change it each time, or consider taking a look at “child themes”.


With that out of the way, there are a few other things you can ditch if you so wish. I’ll start by listing them all and then at the end, giving you a php block to dump into your theme’s functions.php file:

<link rel=”EditURI” type=”application/rsd+xml” title=”RSD” href=”…

This one is used by standalone blog clients, most notably Windows Live Writer. If you’re adding posts to your blog/site via another program that uses the “WordPress XML-RPC interface”, you probably don’t want to ditch this. On the other hand, if you always use the web interface, you don’t need it.

<link rel=”wlwmanifest” type=”application/wlwmanifest+xml” href=”…

I’ll give you a hint. The “wlw” part stands for “Windows Live Writer”. Other standalone blog clients may use it as well though. Similar to the above, if you always use the web interface, you can get rid of this.

<link rel=’next’ title=’something exciting’ href=”…
<link rel=’prev’ title=’something else exciting’ href=”…

You know how sometimes you read an article that spans 5 or 6 pages? That’s what rel=prev and rel=next was intended for…. so that search engines (and perhaps browsers) would get an idea that you’re looking at a series of documents, with these indicating which siblings come immediately before and after.

It works alright when using WordPress on a blog (previous post and next post). Doesn’t really make sense if using WordPress as a CMS though, and you may want to remove them in that case.

<meta name=”generator” content=”WordPress 3.3.2″ />

Guessing you figured out what this one means all on your own. If you want to make it marginally harder for people to figure out that you’re using WordPress (good luck…..), or to find out at a glance that you haven’t upgraded your WP version in years (naughty!), or if you simply want to shave a few bytes from the HTML, you can ditch it.

<link rel=’canonical’ href=’……

For those who don’t know what the “canonical” tag is, search engines use it as a strong hint as to what the proper URL is for a page. For example, if website.com/beans and website.com/healthy/beans and website.com/magicalfruit.html all pointed to the exact same content, Google might not know which one to show as the “preferred” one in the search listings (it’s not going to show all 3 if they’re exactly the same!).

By default, WordPress actually does a good job of keeping this “duplicate content” from happening. So the canonical tag doesn’t really help that much unless you’re doing something a little funky. It may be good practice to keep it, but if you want to drop it, that’s just fine.


Ok, so now that you know (or have a rough idea at least) as to what each does, here’s a block of code you can throw in your theme’s functions.php to get rid of it all!

remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'rel_canonical');

To get to functions.php, simply choose “Appearance/Editor” from the left menu in WordPress, find the functions.php file for your theme, and stick it in. Personally I stick it at the very bottom after everything else – if you’d rather embed it somewhere, feel free to do so (just don’t stick it in the middle of another function unless you know what you’re doing).

Obviously, you can cherry pick the ones you’d like to remove instead of dumping in the whole block – they’re fairly easy to figure out (and I also listed them in the same order as mentioned above).

Again, note that if you upgrade your theme at some point in the future, you’ll lose the changes. So if your theme is prone to frequent updates, you may want to read up on “child themes” and put it in that way. Alternately, there are a few plugins that will do these things, though last I’d checked quite a few weren’t working with the latest version of WordPress (version 3.5).