Skip to content

How To Set WordPress Offline For Scheduled Maintenance

Here’s a snippet which allows you to notify your users when you set your WordPress offline for scheduled maintenance. We will use the wp_die functions. The best part about this code is it only shows the maintenance message for non-admin users, while the website admins can still access the /wp-admin/ path.

Just add the following snippet to your current theme’s functions.php file:

function wp_snippet_maintenance_mode() {
     if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
          wp_die( '<strong>Site offline for maintenance!</strong><br/>Hang on -  we´ll be right back online.<br/>For contact & support - please visit <a href="https://www.trickspanda.com" target="_blank">https://www.trickspanda.com</a> !', 'Site Offline For Maintenance', '');
     }
}
 
add_action('get_header', 'wp_snippet_maintenance_mode');

Leave a Reply

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