Back to Top

How To Put WordPress Site Into Maintenance Mode?

WordPress site into maintenance mode Without Plugin

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

Custom Directives in Angular JS

Posted on 3 years ago

Bhumi

PHP 5 Abstract classes and Methods

Posted on 7 years ago

Bhumi

How to set a Cookie in PHP

Posted on 7 years ago

Bhumi

How to use HTML5 download attribute?

Posted on 4 years ago

Bhumi

Hello world

Updated 1 month ago

Nick Carter

In depth Understanding of Laravel Core

Updated 3 months ago

Bhumi

ECMAScript 6 New Features – 2

Updated 1 year ago

Bhumi

The Reader’s Poll – June 2015

Posted on 4 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 5 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 6 years ago

Bhumi