I will be doing upgrades to the design and content of my WordPress site. During this time I only want the homepage to be available. Is there a good way to lock this down (through a plug-in, etc.).
I’m having trouble coming up with answers from Google.
Thanks,
Jason
Here is a little snipit of code that I used for my site while it was under construction
I put this at the top of my
header.php
.the $underconstruct array is the page/post ids that all not logged in users can see. If they are not logged in and are not on one of the pages that they should be, they get redirected. If the user is logged in, then everything will proceed as normal.
As WordPress is a dynamic web app, it’s hard to have your homepage available when everything else is being updated.
Anytime you run an update for a plugin or WordPress core, it will trigger its maintenance mode. This shows the ‘Briefly unavailable’ page.
Even using the approach above will result in a visitor seeing the standard maintenance page if they try to visit the site as the update script is run.
The best approach I think is to create your own maintenance.php file and this is better than a static page.
.. NB I’m only showing a screen grab of my maintenance page to give you a bit of an idea of what could be achieved.
You can see my maintenance.php in action
Maintenance mode
To put WordPress in Maintenance Mode create a file called
.maintenance
in your/wordpress
folder.I always have mine saved as
aaaa.maintenance
so I can find it.Maintenance mode – logged in users allowed.
This step allows logged in users to access WP-admin and visit the front end.
Edit the
aaaa.maintenance
and insert this code:Create your own maintenance.php
Under
wp-content
create a file calledmaintenance.php
Open the file and add this code:
Make sure the bottom of the file has the
<?php die(); ?>
So now you have your own static page you can invoke anytime you rename aaaa.maintenance to
.maintenance
and you can visit
/wp-admin
even if you are not logged in.