Top

Daily Tip: How to Turn on Maintenance Mode in WordPress

October 11, 2010

Awhile ago we posted an article demonstrating how to put your WordPress site in maintenance mode by editing your .htaccess file. This may be an even easier way to turn on maintenance mode, since you don’t have to use FTP. Simply add this bit to your theme’s functions.php file:

function maintenace_mode() {
  if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
    die('Maintenance.');
  }
}
add_action('get_header', 'maintenace_mode');

This snippet comes to you courtesy of wp-snippets.com, a great new source for helpful WordPress hacks. When you add this snippet it will shut down your site for anyone who is not the admin. When you want the site to return to normal, simply remove the function and you’re back in business.

Tweet This Post

Comments

Got something to say?

Bottom
Article Archive  |  This site is a historical archive of pressography.com, a WordPress plugin and theme blog that published between 2006 and 2012. It is preserved for reference and is not operated by, affiliated with, or endorsed by its original authors. Nothing here is for sale and no form on this site is active. If you are the original owner and would like this domain returned, please get in touch.