There are time when you need to put WordPress into maintenance mode, but don't want to install a full plugin. For example, when you are migrating a website from one host to another, you may want to leave the old site in maintenance mode whilst waiting for the DNS to update.
To do this, just add the following snippet to bottom of the functions.php file of the site