Don’t use template_redirect to load an alternative template file

A short post by Mark Jaquith explaining why you should use the template_include hook instead of template_redirect for loading an alternative template file.

template_redirect is a popular WordPress hook, for good reason. When it runs, WordPress has made its main query. All objects have been instantiated, but no output has been sent to the browser. It is your last stop to hook in and redirect the user somewhere else, and the best place to do so if you need full knowledge of the queried objects. But what it is not good for is loading an alternative template.

Similar Posts