With code to view maintenance mode on WordPress site

Working on our site or blog panel or dashboard is a daily occurrence. But if the work is such that it is not possible to display the content on the homepage at this time. Or in a word: do not allow anyone on your site at this time. What to do then? Then you have to show a message of maintenance mode on your homepage. And we use different types of plugins to do this. But using the plugin makes the site relatively heavy which makes your site take longer to load. So if you wish you can do this on your WordPress site with a shortcode. And all you have to do is:
You need to copy the code from below and add it to the functions.php file.


function wpexplorer_maintenance_mode() {
if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
wp_die('Maintenance, please come back soon.');
}
}
add_action('get_header', 'wpexplorer_maintenance_mode');

As long as this code is in the functions.php file of your WordPress site theme, if someone enters your site, it will show you the message of maintenance mode which is in the above code where Maintenance, please come back soon. Replace there. Thanks.