Activating maintenance mode using a plugin

  1. Go to your site dashboard> Plugins> Add new
    You are going to need a plugin to activate maintenance mode.
    So let’s pick a plugin called WP Maintenance Mode
  2. Install and Activate the plugin
  3. Once activated, you can see the plugin under Settings menu on the left panel of the dashboard
  4. Now you can configure the plugin using three tabs – General, Design, and Modules

To activate maintenance mode, you just need to select the Activate option under the General tab > Save Settings

Activating WooCommerce maintenance mode using snippet code

Alternatively, you can use this snippet code to activate maintenance mode.

// Activate WordPress Maintenance Mode

function wp_maintenance_mode() {

    if (!current_user_can('edit_themes') || !is_user_logged_in()) {

        wp_die('<h1>Under Maintenance</h1><br />Something ain't right, but we're working on it! Check back later.');

    }

}

add_action('get_header', 'wp_maintenance_mode');

Note: Do not apply the code snippet directly to your parent theme as it wipes everything when you update the theme. Use a child theme php.function to use the custom code.

How to use the snippet code

  1. Log into your site dashboard
  2. On the dashboard, go to Appearance>Theme Editor> functions php.
    Activating woocommerce maintenance mode
  3. Then add the above snippet code to the Child theme’s functions php.
    Add snippet code to functions.php file
    You can amend the wording of message in code snippet as shown here> Update the file

That’s how you activate maintenance mode on WooCommerce.