Manually open WordPress site maintenance mode

In an updater or plug-in,WordPressThe front end will show that it is in maintenance mode,If you want to temporarily enable maintenance mode,Let users know that your site is under maintenance,It can be realized by the following code。

openWordPressSite maintenance mode

Add the following code to the current topic function templatefunctions.phpin:

function zm_maintenancemode() {
	if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
		wp_die('Please wait while the website is being maintained!');
		exit;
	}
}
add_action('get_header', 'zm_maintenancemode');

After adding code,前端会显示维护in,But it does not affect the login background operation。

source:http://www.thecreativedev.com/how-to-put-wordpress-site-into-maintenance-mode/

Related Article
WordPress gets the subcategory of the current category

In productionWordPressWhen the theme is often met, how to be inWordPressThe category page displays the subcategories under the current category Read more

The method of forbidding the automatic saving of WordPress articles

Before, Xiao Bian talked about it《solveWordPressarticleidA simple method of discontinuity》Mentioned inWordPress自动保存article的时间间隔的问题,And today we are talking about direct prohibitionWordPressarticle自动保存的方法,The method is Read more

how to automatically add tag links to the article

Today, I'd like to share a WordPress SEO optimization tip, which can realize the automatic addition of keyword tags in Read more

WordPress displays the registration time of the login user in the frontend

When using WordPress to build a website, some users want to display the user registration time in the frontend, but Read more

Leave a Reply

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

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image