With explained hook function over here, you can put WordPress site into Maintenance Mode easily.This is useful if you want to test a design change or new functionality without affecting your readers. So they will know that they are carrying out maintenance tasks.
By placing the following function in functions.PHP, you can see each user who is not logged in or do not have permission to edit the theme rather than enter the site, an error message will be displayed on the site that we want.
1 2 3 4 5 6 7 8 9 | function cd_maintenancemode() { if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) { wp_die('Site is in maintenance Mode.!!'); exit; } } add_action('get_header', 'cd_maintenancemode'); |
That’s it, Now you can see your site is in maintenance mode.
Thank you for reading, good luck and let me know if you run into any problems & I’ll help as much as I can 🙂
Hope this post will helpful for you, waiting for your responses.Thanks for reading and feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.