Features Pricing Docs Blog Log In Get Started Free

WP-CLI Quick Reference

Essential WP-CLI Commands

WP-CLI is the command-line interface for WordPress. On BlitzPress, it is pre-installed and available on all sites. It is the fastest way to manage WordPress without a browser.

Core Management

# Check WordPress version
sudo wp core version --path=$WP --allow-root

# Update WordPress core
sudo wp core update --path=$WP --allow-root

# Verify core file integrity
sudo wp core verify-checksums --path=$WP --allow-root

Plugin Management

# List all plugins
sudo wp plugin list --path=$WP --allow-root

# Install and activate
sudo wp plugin install woocommerce --activate --path=$WP --allow-root

# Deactivate
sudo wp plugin deactivate woocommerce --path=$WP --allow-root

# Update all plugins
sudo wp plugin update --all --path=$WP --allow-root

# Delete
sudo wp plugin delete hello-dolly --path=$WP --allow-root

Theme Management

# List themes
sudo wp theme list --path=$WP --allow-root

# Activate a theme
sudo wp theme activate twentytwentyfour --path=$WP --allow-root

# Install from WordPress.org
sudo wp theme install flavor --activate --path=$WP --allow-root

User Management

# Create admin user
sudo wp user create john [email protected] --role=administrator --user_pass=SecurePass123 --path=$WP --allow-root

# List users
sudo wp user list --path=$WP --allow-root

# Reset password
sudo wp user update 1 --user_pass=NewPassword --path=$WP --allow-root

Database Operations

# Export database
sudo wp db export backup.sql --path=$WP --allow-root

# Import database
sudo wp db import backup.sql --path=$WP --allow-root

# Run a query
sudo wp db query "SELECT COUNT(*) FROM wp_posts WHERE post_type='post';" --path=$WP --allow-root

# Search and replace
sudo wp search-replace "old-url.com" "new-url.com" --dry-run --path=$WP --allow-root

Cache Operations

# Flush object cache
sudo wp cache flush --path=$WP --allow-root

# Flush rewrite rules
sudo wp rewrite flush --path=$WP --allow-root

Options

# Get an option
sudo wp option get blogname --path=$WP --allow-root

# Set an option
sudo wp option update blogdescription "My awesome site" --path=$WP --allow-root

# Delete an option
sudo wp option delete old_plugin_data --path=$WP --allow-root

Tips

  • Always use --path=/home/DOMAIN/public_html to target the correct site
  • Use --allow-root when running as root (common on BlitzPress)
  • Use --format=json for machine-readable output
  • Use --dry-run with search-replace before committing