A collection of useful WP-CLI commands for managing your WordPress site effectively.
Check WordPress version:
wp core version
Update WordPress:
wp core update
List installed plugins:
wp plugin list
Update all plugins:
wp plugin update --all
Install and activate a plugin:
wp plugin install [plugin-name] --activate
List installed themes:
wp theme list
Activate a theme:
wp theme activate [theme-name]
Check inactive themes:
wp theme list --status=inactive
List all users:
wp user list
Create a new user:
wp user create [username] [email] --role=[role]
Reset a user’s password:
wp user update [username] --user_pass=[new-password]
Export the database:
wp db export [filename].sql
Import a database:
wp db import [filename].sql
Optimize the database:
wp db optimize
Check site status:
wp site status
Enable debugging:
wp config set WP_DEBUG true
List scheduled Cron jobs:
wp cron event list
Generate a custom post type
wp scaffold post-type [post-type-name]
Generate a shortcode:
wp scaffold shortcode [shortcode-name]
Generate a new plugin:
wp scaffold plugin [plugin-name]