WordPress CLI commands
A selection of WP-CLI commands
Command | Comment |
---|---|
$ sudo -u USERNAME -- wp COMMAND |
Runs COMMAND as user USERNAME |
$ sudo wp cli update |
Updates WP-CLI itself |
$ wp core update --version=VERSION --force |
Downgrades WordPress to specified VERSION (e.g., 5.0.2) |
$ wp db cli |
Opens a MySQL console using credentials from wp-config.php |
$ wp db export --add-drop-table |
Exports database adding DROP TABLE before each CREATE |
$ wp media image-size |
Lists registered image sizes |
$ wp media import *.png |
Adds all PNG files in current directory to the media library |
$ wp media regenerate |
Regenerates thumbnails for one or more attachments |
$ wp plugin list --status=active |
Lists all active plugins |
$ wp plugin list --status=inactive |
Lists all inactive plugins |
$ wp post delete 99 |
Deletes (to bin) post with ID 99 |
$ wp post delete $(wp post list --cat=9 --format=ids) |
Deletes (to bin) all posts in category with ID 9 |
$ wp post delete $(wp post list --post_status=trash --format=ids) |
Deletes all posts from the trash |
$ wp post update $(wp post list --author=1 --format=ids) --post_author=2 |
Trasfers all entries by user with ID 1 to user with ID 2 |
$ wp post-type list |
Lists registered post types |
$ wp search-replace 'a' 'b' --skip-columns=guid |
Replaces a with b in database skipping the guid column |
$ wp term list category |
Lists categories |
$ wp user list --orderby=ID |
Lists users ordered by ID |
All available WP-CLI commands and subcommands: developer.wordpress.org/cli/commands