Written by Brian Cray on August 19th, 2009
Inside your wordpress <head> element is a bunch of poorly marked-up link elements among other things. The bad code looks like this:
Wordpress junk in my <head>
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://briancray.com/wp-includes/wlwmanifest.xml" />
<link rel='index' title='Brian Cray's Blog' href='http://briancray.com' />
<link rel='start' title='Open for business' href='http://briancray.com/2009/02/05/open-for-business/' />
<link rel='prev' title='5 great examples of popular blog posts that you should know' href='http://briancray.com/2009/08/12/5-great-examples-of-popular-blog-posts-that-you-should-know/' />
<link rel="alternate" type="application/rss+xml" title="Brian Cray's Blog » Delicious.com loses its holy grail Comments Feed" href="http://briancray.com/2009/08/17/delicious-front-page-fails/feed/" />
<meta name="generator" content="WordPress 2.8.4" />
This presents a problem if you
- Want to manually mark up your
<head>; - And/or want to validate, because much of the markup is invalid;
- And/or use HTML5 like I am, because they have closing slashes like so:
<tag />
Remove the Wordpress <head> junk
If you know enough and you'd like to markup your <head> element yourself, insert this code into the file wp-content/your-theme/functions.php.
remove_action('wp_head', 'feed_links_extra');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'parent_post_rel_link');
remove_action('wp_head', 'start_post_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link');
remove_action('wp_head', 'locale_stylesheet');
remove_action('wp_head', 'noindex');
remove_action('wp_head', 'wp_print_styles');
remove_action('wp_head', 'wp_print_head_scripts');
remove_action('wp_head', 'wp_generator');
add_action('wp_head', 'html5_rsd_link');
function html5_rsd_link()
{
echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . '/xmlrpc.php?rsd">' . "\n";
}
If you do this, make sure you manually add these to header.php
- Stylesheets
- RSS and/or ATOM links
- Scripts, if you add them here (I recommend wp_enqueue_script())
Now you have a clean head!
After you've done this, you'll regain full control over your <head> element. Isn't that liberating!?