DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

When you need to do some maintenance on your WordPress blog, you should always make sure that visitors aren’t able to visit your site. Today, I’m going to show you how to easily implement a maintenance mode on your WordPress blog.

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!

Tags

3 Comments

  1. Is there a way to change the Page Title when visitor see that message?

    I want to change the “WordPress > Error” title.

  2. Hi,

    wp_die(‘Maintenance, please come back soon.’, ‘Your Website Name’);

    😉

  3. Is there a way to add a login box for admins?

Leave a Comment

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