How to put your WordPress website in maintenance mode without a plugin

Sometimes, when things go wrong and you end up with a broken website with all the errors, warnings or notices visible to anyone who’s trying to access your website. In these cases, you don’t want your visitors to visit your website. So, its better to put it under maintenance mode until it is fixed.

To put you website in a maintenance mode, all you need to do is copy the following WordPress code snippet and paste it inside your functions.php file

// Activate WordPress Maintenance Mode
function wp_maintenance_mode(){
    if(!current_user_can('edit_themes') || !is_user_logged_in()){
        wp_die('<h1 style="color:red">Website under Maintenance</h1><br />We are performing scheduled maintenance. We will be back on-line shortly!');
add_action('get_header', 'wp_maintenance_mode');

How to put your WordPress Website in Maintenance Mode Without a Plugin

This function will temporarily shutdown your website for all the visitors, but it will be still accessible by administrators, allowing them to make the necessary changes in order to fix the problems.

To disable the maintenance simply comment or delete the code.


  1. I agree that its important we learn how to switch our website to maintenance mode. Just recently I had to switch from my former hosting company to a new one due to issues that caused my site frequent down times. I moved my files to the new host but were it not for the maintenance plugin. I would have lost visitors who would think that my site is broken . Thanks for sharing and this will help everyone.


Leave a Comment.