WordPress Maintenance Mode

Sometimes you need a quick maintenance mode for WordPress. Instead of installing a plugin, you can use this snippet and comment it out when you don’t want it switched on anymore. It will display the following text for visitoris trying to reach your site: Maintenance mode. Our site is currently undergoing scheduled maintenance. Please try back in 10 minutes. Sorry for the inconvenience.”

Add the following snippet to your functions.php to switch to maintenance mode:

function maintenace_mode() {

if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
wp_die('Maintenance mode. Our site is currently undergoing scheduled maintenance. Please try back in 10 minutes. Sorry for the inconvenience.');
}
}
add_action('get_header', 'maintenace_mode');

Don’t forget to remove the snippet when your are done!

Gillade du inlägget?

   
       

Kommentera

E-postadressen publiceras inte. Obligatoriska fält är märkta *