WordPress Theme Authors, Don’t Forget The wp_head() Function

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”]

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.


  1. Is it the or the that pulls in WordPress.com stats?

  2. My code markup go stripped… Is it the wp_head or wp-footer that pulls in stats?

  3. The WordPress.com stats plugin uses the wp_footer action to insert the tracking code.

  4. 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.

  5. Agreed, wp_footer() is also an important part of every theme.

  6. Will using wp_head() cause any styling issues? or is it simply giving the theme access to internal WordPress functionality?

  7. 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.

  8. Thank you!! You fixed my problem! I had edited my Header and took the tag out

  9. 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.

  10. No wonder my stats weren’t working! Thanks for the “duh” moment. 🙂

  11. 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

  12. Sounds like you’ve got something hooking into wp_head that is taking a long time to process. Could be a plugin or theme.

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2019 Joseph Scott

Theme by Anders NorénUp ↑