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>
1 2 3 4 5 6 | <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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 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!?
Published August 19, 2009. Tagged: php, wordpress. Read it later with Instapaper