When creating a WordPress theme don’t forget to include a wp_head(); call in the HTML HEAD section of your theme. It’s very simple to do, just include:
[sourcecode lang=”php”]
wp_head();
[/sourcecode]
Before the closing HEAD tag (</head>) in your HTML.
Why make such a fuss over a single function call? Because it does a fair bit of work behind the scenes and without it some WordPress features will not work properly. Take a look at the wp_head section of the wp-includes/default-filters.php file in WordPress, you’ll see a number of events that are tied to the wp_head action.
One area where this is a particular problem is for offline blog clients that make use of the XML-RPC and AtomPub APIs in WordPress. The “Really Simple Discoverability” (RSD) link that WordPress inserts instructs these clients on where to find the RSD URL, which contains information on how the clients can send XML-RPC and AtomPub requests. We’ve seen a number of times now where an error reported by a WordPress iPhone App user is caused because there is no RSD link in their WordPress blog. Looking a little deeper reveals that there was no RSD link because the theme they were using didn’t include a call to wp_head().
If you are writing a WordPress theme here is your reminder, make sure that the wp_head() function is being called at the end of your HEAD section.
Wed 8 Apr 2009 at 2:52 pm
Is it the
or the
that pulls in WordPress.com stats?
Wed 8 Apr 2009 at 2:53 pm
My code markup go stripped… Is it the wp_head or wp-footer that pulls in stats?
Wed 8 Apr 2009 at 3:08 pm
The WordPress.com stats plugin uses the wp_footer action to insert the tracking code.
Sat 11 Apr 2009 at 6:34 am
With 2.8 adding the functionality to enqueue scripts into the footer, as well as this is where the wp.com stats plugin puts the tracking code, theme authors need to remember to include wp_footer() also.
Sat 11 Apr 2009 at 8:09 pm
Agreed, wp_footer() is also an important part of every theme.
Mon 18 May 2009 at 10:28 am
Will using wp_head() cause any styling issues? or is it simply giving the theme access to internal WordPress functionality?
Mon 18 May 2009 at 4:59 pm
I don’t think any of the default actions (see wp-includes/default-filters.php) will change the styling at all. Any theme that doesn’t call wp_head() should be considered broken. There are core features of WordPress that require it in order to work. In addition to RSD there’s: wp_enqueue_scripts (makes sure the correct Javascript files get included in pages), WLW manifest file (tells Windows Live Writer what features WP supports) and comment threading Javascript. That isn’t a complete list, just the highlights.
There are also plugins that make us of wp_head() as well.
Thu 30 Jul 2009 at 5:01 pm
Thank you!! You fixed my problem! I had edited my Header and took the tag out
Tue 29 Sep 2009 at 9:12 pm
Thank you, this cleared up a problem I had with the WP-Polls plugin. I had removed BOTH wp_head and wp_footer from my template a long time ago when I knew much less about theming, and only recently have begun to pay for it with mysterious plugin problems. This warning should be emblazoned on EVERY beginner themer’s guide out there.
Fri 1 Apr 2011 at 2:35 pm
No wonder my stats weren’t working! Thanks for the “duh” moment. 🙂
Mon 3 Sep 2012 at 2:16 pm
wp_head makes my site very slow. In average, 2.5 seconds on 3.6 needed for the whole page.
I’ve removed action in wp_head (may be the list useful) but i can’t resolve this problem.
Any ideas ?
Best regards from Paris, France
Mon 3 Sep 2012 at 11:05 pm
Sounds like you’ve got something hooking into wp_head that is taking a long time to process. Could be a plugin or theme.