WP-CLI is the command-line interface for WordPress. Instead of clicking through the admin dashboard, you can update plugins, manage users, run database operations, and deploy sites from the terminal. WP-CLI 2.0 was released in 2018 and supports WordPress 3.7 and up.
Problem: Managing WordPress from the admin dashboard — activating plugins, checking updates, running database operations — is slow and impractical when you need to automate tasks or work over SSH.
Solution: Use WP-CLI to run any WordPress operation from the command line. The reference below groups the most frequently used commands by category: core, plugins, themes, users, database, and cron.
Core management:
# Check WP-CLI version and WordPress version
wp --version
wp core version
# Download WordPress core
wp core download --locale=en_US
# Install WordPress (creates wp-config.php and runs the installer)
wp core install --url="https://example.com" --title="My Site" --admin_user="admin" --admin_email="admin@example.com" --admin_password="secret"
# Update WordPress core
wp core update
# Check for available updates
wp core check-update
Plugin and theme management:
# List all plugins with status
wp plugin list
# Install and activate
wp plugin install contact-form-7 --activate
# Update all plugins
wp plugin update --all
# Deactivate and delete
wp plugin deactivate my-plugin
wp plugin delete my-plugin
# Same commands work for themes
wp theme list
wp theme install twentynineteen --activate
Database and options:
# Search and replace in the database (handles serialized data correctly)
wp search-replace 'http://staging.example.com' 'https://example.com' --skip-columns=guid
# Export / import the database
wp db export backup.sql
wp db import backup.sql
# Get/set options
wp option get siteurl
wp option update blogname "My New Site Name"
# Flush rewrite rules and cache
wp rewrite flush
wp cache flush
User management:
# List users
wp user list --fields=ID,user_login,user_email,roles
# Create a new admin user
wp user create editor editor@example.com --role=editor
# Reset a password
wp user update 1 --user_pass="newpassword"
# Generate a one-time login URL (great for debugging without knowing the password)
wp user session destroy --all 1
wp user reset-password 1
NOTE: Always run wp search-replace with --dry-run first to preview changes before applying them. The --skip-columns=guid flag prevents changing the guid column, which should never be altered after a post is created.