How to Use WP-CLI on Shared Hosting
WP-CLI is the command-line interface for WordPress. It lets you manage WordPress without using the browser — update plugins, manage users, import/export content, and more.
Accessing WP-CLI
WP-CLI is pre-installed on {{COMPANY_NAME}} shared hosting servers. Access it via SSH or the cPanel Terminal.
Via SSH
- Connect via SSH to your hosting account.
- Navigate to your WordPress directory:
bash
cd ~/public_html- Run WP-CLI commands:
bash
wp --infoVia cPanel Terminal
- Log in to cPanel.
- Go to Advanced > Terminal.
- Navigate and run commands.
Essential WP-CLI Commands
Check WordPress Status
bash
wp core version # Show WordPress version
wp core check-update # Check for updates
wp --info # Show WP-CLI and PHP infoUpdate WordPress
bash
wp core update # Update WordPress core
wp core update-db # Update database after core updatePlugin Management
bash
wp plugin list # List all plugins
wp plugin status # Show plugin statuses
wp plugin install akismet # Install a plugin
wp plugin activate akismet # Activate a plugin
wp plugin deactivate akismet # Deactivate a plugin
wp plugin update --all # Update all plugins
wp plugin delete old-plugin # Delete a pluginTheme Management
bash
wp theme list # List all themes
wp theme activate twentytwentyfour # Activate a theme
wp theme update --all # Update all themesUser Management
bash
wp user list # List all users
wp user create john [email protected] --role=editor # Create user
wp user update 1 --user_pass=NewPassword123 # Reset passwordDatabase Operations
bash
wp db optimize # Optimise database tables
wp db repair # Repair database
wp db export backup.sql # Export database
wp db import backup.sql # Import database
wp db search "old-text" # Search in database
wp search-replace "old" "new" # Search and replace in databaseCache Management
bash
wp cache flush # Flush object cache
wp transient delete --all # Delete all transients
wp rewrite flush # Flush rewrite rulesContent Management
bash
wp post list # List posts
wp post delete 123 --force # Delete a post
wp comment delete $(wp comment list --status=spam --format=ids) --force # Delete all spam commentsMaintenance
bash
wp cron event list # List scheduled cron events
wp cron event run --all # Run all pending cron events
wp option get siteurl # Check site URL
wp option update siteurl "https://yourdomain.com" # Update site URLCommon Use Cases
Fix Locked Out of wp-admin
bash
wp user create tempadmin [email protected] --role=administrator --user_pass=TempPass123!Log in with the temporary admin, fix the issue, then delete the temp user.
Fix White Screen of Death
bash
wp plugin deactivate --all # Deactivate all pluginsThen reactivate one by one to find the problematic plugin.
Migrate Domain
bash
wp search-replace "https://old-domain.com" "https://new-domain.com"Tip: WP-CLI is much faster than the WordPress admin for bulk operations like updating all plugins, cleaning spam comments, or running search-replace across the database.
Related Articles
- How to Set Up SSH Access on Shared Hosting
- How to Install WordPress on cPanel
- cPanel Hosting Features Overview
Need help? Contact our support team at {{SUPPORT_URL}}/client/support.