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