WordPress tip: Quick maintenance mode

Paste the following code into your functions.php file. Don’t forget to remove the code once you’re done with maintenance!

function wpr_maintenance_mode() {
    if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
        wp_die('Maintenance, please come back soon.');
    }
}
add_action('get_header', 'wpr_maintenance_mode');

Thanks to Skyje for the cool tip!

Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!

WordPress tip: Quick maintenance mode

Leave a Reply

Your email address will not be published. Required fields are marked *