when should an action be added to init and when should it be added to wp_head

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.

Leave a Comment