large shade tree



Recent Posts

Shade Tree Sites |Building Better Websites

WordPress Temporary Maintenance Mode

This snippet  temporarily closes down your site to visitors but allows access to admins.
To allow visitors again simply delete or comment out the function.

Add to functions.php:

// Temp Maintenance  (503 Service Temporarily Unavailable)
// Only blocks users who are NOT an administrator from viewing the website
function wp_maintenance_mode(){
if(!current_user_can(‘edit_themes’) || !is_user_logged_in()){
wp_die(‘Temporary maintenance, we’ll be back soon.’, ‘Temporary maintenance – we’ll be back soon.’, array(‘response’ => ‘503’));

<add_action(‘get_header’, ‘wp_maintenance_mode’);