11

During theme or plugin upgrades, maintenance mode is enabled and then disabled once complete.

Is it possible to manually enable / disable maintenance mode?

Enabling Maintenance mode... Downloading update from xxxx Disabling Maintenance mode...

3 Answers 3

7

WP-CLI now has native commands for it.

# Activate Maintenance mode
$ wp maintenance-mode activate
# Deactivate Maintenance mode
$ wp maintenance-mode deactivate

See wp-cli/maintenance-mode-command for more information.

0
9

You can enable maintenance mode in WordPress by adding a .maintenance file to your root WordPress directory. It will need to include:

<?php
$upgrading = time();

With this file in place, your site will be in maintenance mode until you remove the file.

3
  • 4
    To add to that, WordPress looks at the timestamp of $upgrading and if it's more than 10 minutes old assumes the maintenance window has passed, and ignores the .maintenance file. Feb 10, 2016 at 15:54
  • Which is not what OP asked for. They want to know how to do that using WP-CLI.
    – leymannx
    Apr 25, 2019 at 20:23
  • 1
    @leymannx There wasn't a way to enable / disable maintenance mode with WP-CLI at the time of my posting. Apr 26, 2019 at 21:02
2

I use a plug-in for maintenance mode and always leave it "in" maintenance mode.

Practically you can then turn on/off the actual maintenance mode by turning on/off that plugi-in — which is easy through wp-cli:

# activate maintenance mode, flush caches and stuff
wp plugin activate ultimate-maintenance-mode
# do maintenance things
wp plugin deactivate ultimate-maintenance-mode
# flush caches again so the maintenance page does not show up
3
  • 1
    Great workaround! Although I can't believe there isn't a native feature in wp-cli that does that.
    – pagliuca
    Nov 19, 2017 at 21:04
  • There doesn't seem to be a native WordPress function that does this, so wp-cli has nothing to call on.
    – Slam
    May 18, 2018 at 22:07
  • The Plugin is removed now. Mar 28, 2022 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.