Regular maintenance of a WordPress site is essential to ensure its smooth functioning and to keep it secure from cyber threats. When you update your WordPress site or make any changes to it during maintenance, it’s a good practice to put it in maintenance mode.
It will notify visitors that the site is undergoing maintenance and prevent them from accessing it while the updates are being made. In this tutorial, we’ll show you how to enable WordPress maintenance mode manually in PHP while doing updates during regular maintenance.
Step 1: Create a Maintenance Page
The first step is to create a maintenance page that will be displayed to visitors when they try to access your site during maintenance. You can create a simple HTML file with a custom message or use a pre-built maintenance page template. There are several free and premium maintenance page templates available online that you can use.
Step 2: Create a .maintenance File
The second step is to create a .maintenance file in the root directory of your WordPress installation. This file will tell WordPress to put the site in maintenance mode. You can create the file using a code editor or the terminal. Here’s the code you need to add to the file:
The “time()” function sets the time stamp for when the maintenance mode was enabled, and the “touch()” function creates the .maintenance file.
Step 3: Upload the Maintenance Page and .maintenance File
The next step is to upload the maintenance page and .maintenance file to your WordPress site’s root directory using FTP or the File Manager in your hosting control panel.
Step 4: Disable Maintenance Mode
Once you have completed your updates or maintenance tasks, you can disable the maintenance mode by deleting the .maintenance file from the root directory. Alternatively, you can remove the code from the .maintenance file to disable maintenance mode.
Enabling maintenance mode during updates or maintenance tasks offers several benefits, including:
Improving User Experience: Putting your site in maintenance mode informs visitors that the site is undergoing maintenance, and they cannot access it at the moment. This reduces the risk of them encountering any errors or broken pages and ensures a better user experience.
Preventing Site Downtime: Maintenance mode ensures that your site remains online and doesn’t experience any downtime during updates or maintenance tasks.
Avoiding Broken Links: When you make updates or changes to your WordPress site, it’s possible that some links may become broken, leading to 404 errors. Enabling maintenance mode during updates ensures that visitors cannot access your site during the update process, preventing them from encountering broken links. This helps maintain the credibility and reputation of your site.
Yes, you can create a custom maintenance page with your own design and message.
The duration of maintenance mode depends on the updates or maintenance tasks you need to perform. It’s recommended to keep the site in maintenance mode until you have completed all the necessary updates or maintenance tasks.
Yes, you can still access the WordPress admin panel by adding /wp-admin/ to the end of your site’s URL.
Yes, you can use plugins or custom code to enable maintenance mode for a specific page or section of your site.
Enabling WordPress maintenance mode manually in PHP while doing updates during regular maintenance is a simple process that can greatly improve user experience and prevent errors. By following the steps outlined in this tutorial, you can ensure that your site remains online and accessible to visitors during maintenance tasks while still keeping them informed about the maintenance process. Remember to disable maintenance mode once you have completed your updates or maintenance tasks.
Copyright © Web Solutions Express
Icons created by Freepik – Flaticon