WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do you know when to add your action to init or wp_head. In particular with regards to scripts and styles, but also any other action.

share|improve this question
up vote 5 down vote accepted

From Codex Action Reference:

init Runs after WordPress has finished loading but before any headers are sent. Useful for intercepting $_GET or $_POST triggers.

wp_head Runs when the template calls the wp_head function. This hook is generally placed near the top of a page template between <head> and </head>. This hook does not take any parameters.

Basically wp_head runs when page is already being loaded, while init runs before that.

Also don't forget that init fires on admin pages as well and anything front-end related must be excluded from there with !is_admin() check.

share|improve this answer
Brilliant, thanks – Ash G Sep 29 '10 at 8:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.