WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

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!!

share|improve this question

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.

share|improve this answer
This is best answer, since template_redirect is used for what it says - page redirection. – mjakic Oct 21 '15 at 15:17

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.