[wp-hackers] Hook locations

John Blackbourn johnbillion+wp at gmail.com
Sat Apr 7 14:24:48 UTC 2012

On 7 April 2012 13:54, Doug Stewart <zamoose at gmail.com> wrote:
> I know I've seen plenty of hook lists in the wild before but I don't
> think I've ever seen documentation as to when each of them fires. I'm
> interested in figuring out
> 1) the first hook that produces actual output

The first thing that outputs any markup is actually the theme (or, it
should be). The 'template_redirect' hook is the closest one to before
the theme files are loaded, but it still fires before anything output
by the theme. If you want to output something after the DOCTYPE then
it can only reliably be 'wp_head', which fires within the head.

> 2) the last hook that fires in the head

Also 'wp_head', as there's only one hook in the head.

> 3) the last hook that fires before end-of-rendering

'wp_footer' if you want to remain within the <html> element, or
'shutdown' which is the last hook to fire after everything is done and

More information about the wp-hackers mailing list