WP-CLI Access on WP Pro Host

WP-CLI is available on all WP Pro Host plans via SSH. Connect to your account using your SSH credentials from the Enhance CP control panel, and WP-CLI is available globally as wp.

ssh username@your-server.wp-pro-host.com
wp --info

Verify you’re running the current version: wp --version. If you need a specific WP-CLI version for compatibility, you can install it locally in your site directory.

Common Migration Commands

When migrating a site to or from WP Pro Host, WP-CLI’s search-replace command is essential for updating serialized URLs in the database:

# Export database from old host
wp db export old-site-backup.sql

# Import on new host
wp db import old-site-backup.sql

# Update all URLs in the database
wp search-replace 'https://old-domain.com' 'https://new-domain.com' --all-tables

# Verify the replacement
wp search-replace 'https://old-domain.com' 'https://new-domain.com' --all-tables --dry-run

Always run with --dry-run first to verify what will change before committing.

Plugin and Theme Management

WP-CLI makes bulk plugin and theme operations fast — particularly useful when managing multiple client sites or setting up a new site from a standard configuration:

# List all plugins with update status
wp plugin list --format=table

# Update all plugins
wp plugin update --all

# Install a plugin
wp plugin install query-monitor --activate

# Deactivate all plugins (useful for conflict debugging)
wp plugin deactivate --all

# Update all themes
wp theme update --all

Database Maintenance

WP-CLI exposes database operations that are otherwise only available via phpMyAdmin or direct MySQL access:

# Clean up expired transients
wp transient delete --expired

# Optimise database tables
wp db optimize

# Check for database errors
wp db check

# Get database size
wp db size

# Delete post revisions (run with caution on production)
wp post delete $(wp post list --post_type='revision' --format=ids) --force

Automate database maintenance as a cron task using WP-CLI — add a server cron job to run transient cleanup weekly.

LiteSpeed Cache via WP-CLI

The LiteSpeed Cache plugin exposes WP-CLI commands for cache management — useful in deployment workflows:

# Purge all cached pages
wp litespeed-purge all

# Purge a specific URL
wp litespeed-purge url https://yourdomain.com/specific-page/

# Warm the cache (crawl and cache key pages after deployment)
wp litespeed-option set crawler_run_duration 400
wp litespeed-crawler start

WordPress Multisite Operations

For WordPress Multisite installations (common for agency portfolios and multi-brand setups), WP-CLI’s --url flag targets specific subsites:

# List all sites in a multisite network
wp site list

# Run a command on a specific subsite
wp --url=subsite.yourdomain.com plugin update --all

# Run a command across all subsites
wp site list --field=url | xargs -I % wp --url=% plugin update --all

Automating Repetitive Tasks

WP-CLI commands can be scripted and scheduled via cron. A simple deployment script that runs after file changes are deployed:

#!/bin/bash
# post-deploy.sh
cd /path/to/wordpress

# Update database if WordPress version changed
wp core update-db

# Flush rewrite rules
wp rewrite flush

# Clear LiteSpeed cache
wp litespeed-purge all

# Run any pending database migrations
wp option update db_version $(wp core version --extra | grep db_version | awk '{print $2}')

echo "Deployment complete"

Debugging with WP-CLI

WP-CLI’s --debug flag provides verbose output useful for diagnosing configuration issues:

# Run any command with debug output
wp plugin list --debug

# Check WordPress installation for common issues
wp doctor check --all

# Verify PHP constants and configuration
wp eval 'echo WP_DEBUG; echo PHP_MAJOR_VERSION;'

The wp doctor check command runs a set of health checks and is useful as part of a site audit workflow.

Frequently Asked Questions

Is WP-CLI available on managed WordPress hosting?

Yes. WP-CLI is available on all WP Pro Host plans via SSH. Connect using your SSH credentials from Enhance CP and WP-CLI is available globally as the wp command. Verify the installation with wp --info. All standard WP-CLI commands are available including database operations, plugin management, search-replace, and LiteSpeed Cache integration.

How do I migrate a WordPress site using WP-CLI?

Export the database from the old host with wp db export old-site-backup.sql, transfer to the new host, import with wp db import, then update all serialised URLs with wp search-replace 'https://old-domain.com' 'https://new-domain.com' --all-tables. Always run with --dry-run first to verify what will change. This correctly handles serialised data in the database that a simple SQL find-and-replace would break.

How do I update all WordPress plugins using WP-CLI?

Run wp plugin update --all to update everything in one command. Use wp plugin list --format=table first to see current plugin status including available updates. For selective updates specify the slug: wp plugin update woocommerce. For multiple sites, script this in a bash loop or run it via a deployment pipeline.

How do I clean up a WordPress database with WP-CLI?

Run wp transient delete --expired to remove expired transients, wp db optimize to optimise tables, and wp db check to identify errors. Remove bloating post revisions with wp post delete $(wp post list --post_type='revision' --format=ids) --force. These are best scheduled as a weekly server cron job to maintain consistent database performance over time.

Can WP-CLI be used in automated deployment scripts?

Yes. WP-CLI commands can be scripted in bash and executed via SSH in CI/CD pipelines or cron jobs. A typical post-deployment script runs wp core update-db to apply schema changes, wp rewrite flush to refresh permalink rules, and wp litespeed-purge all to clear the page cache. This is more reliable than manual cache clearing and can be triggered automatically on every deployment.