I want to build a very simple toggle for taking my site down into a maintenance mode. To do that, I want to add a admin area to define a template that is the maintenance page, and allow that page to override the database defined template when maintenance mode is switched on.
How can I change the theme template called for each page, WITHOUT affecting the database?
you can use
template_redirect
action hook to php include your maintenance mode template file using a simple option in options database.When you turn maintenance mode on add an option for example:
then with this code you check if that option is set and if so you redirect to your desired template file:
Then when you turn maintenance mode off delete that option :
Update
If you want to effect the
body_class()
you can usebody_class
filter hook:This will change the body_class() to output
maintenance
when maintenance mode is turned on.