Is it possible to change the template loaded for a page, as it loads, without having to change the record in the database?

I suspect it can be done with the template_redirect action, and the will probably have something to do with the template-loader.php file in the WP core, but I can't figure it out.

Any pointers would be grand!!

1 Answer 1


Just in case someone comes here to copy pasta without looking at the codex.

THE APPROPRIATE FILTER IS »template_include«

See: Codex - Filter Reference

As Radek pointed out that method can destroy your theme.

Additional information: The article »Don’t use template_redirect to load an alternative template file« by Mark Jaquith, where he says, in a nutshell, template_redirect is for redirects, template_include is for includes.

  • This is best answer, since template_redirect is used for what it says - page redirection.
    – mjakic
    Oct 21, 2015 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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