How to Enable Maintenance Mode in WordPress Without Plugins
How to enable maintenance mode in wordpress;
Wordpress maintenance mode plugin;
Put wordpress site in maintenance mode;
Enable wordpress maintenance mode manually;
Wordpress maintenance mode settings;
Activate maintenance mode wordpress;
Wordpress site maintenance mode tutorial;
How to turn on maintenance mode in wordpress;
Wordpress maintenance mode without plugin;
Wordpress maintenance mode page setup;
Explanation
To put your WordPress site into maintenance mode without using a plugin, you can add a small piece of code to your theme's functions.php file. This code will temporarily block access to your site for visitors, showing them a maintenance message instead.
Here's how it works:
- The code checks if the person visiting your site is logged in and has permission to edit themes. If not, they will see a maintenance message.
- The message displayed is simple: "Our website is currently undergoing scheduled maintenance. Please check back soon."
- The HTTP response code is set to 503, which tells search engines that the site is temporarily unavailable due to maintenance.
Remember, this code should be removed or commented out once your maintenance is complete to allow visitors to access your site again.
Code
<?php
// Enable Maintenance Mode in WordPress
function wp_dudecom_enable_maintenance_mode() {
if ( ! current_user_can( 'edit_themes' ) || ! is_user_logged_in() ) {
wp_die(
'<h1>Maintenance Mode</h1><p>Our website is currently undergoing scheduled maintenance. Please check back soon.</p>',
'Maintenance Mode',
array( 'response' => 503 )
);
}
}
add_action( 'get_header', 'wp_dudecom_enable_maintenance_mode' );
?>
Instructions
File Location: functions.php of your active theme.
Prerequisites:
- Access to your WordPress admin dashboard.
- Basic understanding of how to edit theme files.
- Backup your functions.php file before making changes.
Implementation Steps:
- Log in to your WordPress admin dashboard.
- Navigate to Appearance > Theme Editor.
- In the right-hand sidebar, locate and click on functions.php to open it for editing.
- Scroll to the bottom of the functions.php file.
- Copy and paste the provided code snippet into the file.
- Click the Update File button to save your changes.
- Visit your website in a private browsing window or log out to verify that the maintenance mode message is displayed.
- Once maintenance is complete, remove or comment out the code to restore normal site access.
If you need assistance with this implementation or require more advanced functionality, consider reaching out to wp-dude.com for expert help.