My Journal



Cleaning WordPress Header by Removing Unnecessary Code

in your wordpress CMS you notice there are alot of stuffs through the wp_head() hook included on most well known themes and most of this stuffs is considered unnecessary, specially when using wordpress as a small business CMS rather than of a blog

Read on for the description of each of these to see if you need them or not, and how to remove them.

Really Simple Discovery
This is the code that displays the following code in your header:

[php]<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://domain.tld/xmlrpc.php?rsd" />[/php]

This is the discover mechanism used by XML-RPC clients. If you have no idea what this means and/or don’t integrate services like Flickr with your WordPress site, it’s probably safe to remove it with the following code in your theme’s functions file.

[php]remove_action(‘wp_head’, ‘rsd_link’);[/php]

Windows Live Writer
This is why you see the following code in your header.

[php]<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://domain.tld/wp-includes/wlwmanifest.xml" />[/php]

If you don’t use Windows Live Writer, then this code is completely useless to you and should be removed.

[php]remove_action(‘wp_head’, ‘wlwmanifest_link’);[/php]

WordPress Generator

This is what displays your WordPress version number in your header.

[php]<meta name="generator" content="WordPress 2.8.4" />[/php]

Noone really needs to know the exact version of WordPress you’re using, so it’s safe to remove this line of code.

[php]remove_action(‘wp_head’, ‘wp_generator’);[/php]

Post Relational Links
Post relational links are why this stuff is displayed on various pages.

<link rel=’index’ title=’Main Page’ href=’http://www.domain.tld’ />
<link rel=’start’ title=’Article in the distant past’ href=’http://www.domain.tld/hello-world/’ />
<link rel=’prev’ title=’The Post Before This One’ href=’http://www.domain.tld/post-before/’ />
<link rel=’next’ title=’The Post After This One’ href=’http://www.domain.tld/post-after/’ />

Some browsers may use this code to navigate your site, although you can probably get the same effect from a well designed theme. You’ll need three lines to nuke them all

remove_action(‘wp_head’, ‘start_post_rel_link’);
remove_action(‘wp_head’, ‘index_rel_link’);
remove_action(‘wp_head’, ‘adjacent_posts_rel_link’);

Functions.php Template

For your convenience, here’s all of them combined for easy copying and pasting into your own theme’s functions.php file.

remove_action(‘wp_head’, ‘rsd_link’);
remove_action(‘wp_head’, ‘wlwmanifest_link’);
remove_action(‘wp_head’, ‘wp_generator’);
remove_action(‘wp_head’, ‘start_post_rel_link’);
remove_action(‘wp_head’, ‘index_rel_link’);
remove_action(‘wp_head’, ‘adjacent_posts_rel_link’);

    • victor gonzalez
      Jun 4, 2011 at 5:29 PM / Reply

      i love your site. subscribed. Thank you for sharing your knowledge 🙂

    • Fanatic
      Jun 23, 2011 at 5:22 AM / Reply

      Anyone know to remove the meta name version code??
      I have this line of code on all the pages which is totally useless:

Leave A Comment