WordPress maintenance mode

Updated: 10 September 2022

Use in theme functions.php or a plugin to put WordPress into maintenance mode.

function wp_maintenance_mode() {
    if ( ! current_user_can('edit_themes' ) || ! is_user_logged_in() ) {
        wp_die('Under Maintenance.');
    }
}
add_action( 'get_header', 'wp_maintenance_mode' );

Leave a comment