Change template dynamically

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.

Read More

Any pointers would be grand!!

Related posts

Leave a Reply

1 comment

  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.