How to Turn on Maintenance Mode in WordPress

How to Turn on Maintenance Mode in WordPress

A while ago we posted an article demonstrating how to put your WordPress site in maintenance mode by editing your .htaccess file.

This may be an even easier way to turn on maintenance mode since you don’t have to use FTP. Simply add this bit to your theme’s functions.php file:

function maintenance_mode() {
if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
die('Maintenance.');
}
}
add_action('get_header', 'maintenance_mode');

When you add this snippet it will shut down your site for anyone who is not the admin. When you want the site to return to normal, simply remove the function and you’re back in business.

Free Video Why 100 is NOT a Perfect Google PageSpeed Score (*5 Min Watch) Learn how to use Google PageSpeed Insights to set realistic goals, improve site speed, and why aiming for a perfect 100 is the WRONG goal.