You can put WordPress into maintenance mode using two methods – manually forcing it via code or with a WordPress maintenance mode plugin.
For the former, you can enable maintenance mode on your WordPress site by adding the following code snippet to your site’s functions.php file:
// Activate WordPress Maintenance Mode
function wp_maintenance_mode(){
if(!current_user_can('edit_themes') || !is_user_logged_in()){
wp_die('<h1 style="color:red">Website under Maintenance</h1><br />We are performing scheduled maintenance.We will be back on-line shortly!');
}
}
add_action('get_header', 'wp_maintenance_mode');
If you want to force maintenance mode in WordPress via a plugin, you have a handful of options. Some we recommend include Maintenance, WP Maintenance Mode, and the Coming Soon and Maintenance Mode plugin.