WordPress

The most important WP-CLI commands — a cheat sheet

An annotated cheat sheet of the WP-CLI commands you'll use over and over — from core updates to resetting an admin password.

WP-CLI has hundreds of commands, but in practice the same handful come back again and again. Here’s a cheat sheet to save. Run them all from your WordPress root after you’ve SSH’d in.

Core

wp core version                 # which WP version am I running?
wp core update                  # update WordPress core
wp core update-db               # run database updates afterwards
wp core verify-checksums        # are the core files untouched? (malware check)

Plugins & themes

wp plugin list --update=available
wp plugin update --all
wp theme update --all
wp plugin deactivate --all       # quick debugging: turn everything off

Database

wp db export backup.sql          # back up the database
wp db import backup.sql          # restore it
wp search-replace 'old' 'new' --dry-run
wp db optimize                   # clean up and optimize tables

Users

Locked out? This resets an admin password in seconds — invaluable when you can’t get into wp-admin.

wp user list
wp user create anna anna@example.com --role=administrator
wp user update admin --user_pass='a-new-strong-password'

Cache, transients & maintenance

wp cache flush                   # empty the object cache
wp transient delete --all        # clear all transients
wp rewrite flush                 # rebuild permalink rules
wp maintenance-mode activate     # put the site in maintenance mode

Config & debugging

wp config get table_prefix
wp config set WP_DEBUG true --raw    # turn on debug mode
wp cron event list                  # do scheduled jobs look odd?
wp option get siteurl

Tip: add --help after any command (wp plugin --help) to see every flag. And wp --info shows your environment when something misbehaves.

The full WP-CLI series

Rather not do it yourself? At Kepler, WP-CLI and SSH access are part of Managed WordPress — we keep core, themes and plugins updated for you. And you can always SSH into your own cloud server and run the commands above whenever you like.

Bygg på ett moln du faktiskt äger.

Ingen bindningstid. En körande VM innan du betalar en krona.