You can update plugins, configure multisite installs and much more, without using a web browser.
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp --info
wp core config --dbhost=localhost --dbname=testing --dbuser=wp --dbpass=securepswd --dbprefix=wp_
List all users
wp user list
Create user
wp user create bob [email protected] --role=author
Update user with ID 123
wp user update 123 --user_pass=newpass
Delete user 123 and reassign posts to user 567
wp user delete 123 --reassign=567
wp server
wp server --host=0.0.0.0
sudo wp server --host=localhost.localdomain --port=80
List Plugins
wp plugin list
Install and activate plugin at once
wp plugin install --activate akismet
Deactivate plugin
wp plugin deactivate akismet
Delete plugin without deactivating or uninstalling
wp plugin delete akismet
Update plugins
wp plugin update akismet
wp plugin update --all
To regenerate a .htaccess file with WP-CLI, you’ll need to add the mod_rewrite module to your wp-cli.yml or config.yml.
Create wp-cli.yml
file and write below
apache_modules:
- mod_rewrite
Flush rewrite rules.
wp rewrite flush
Update the permalink structure
wp rewrite structure '/%postname%'
[--hard]
Perform a hard flush - update .htaccess rules as well as rewrite rules in database. Works only on single site installs.
wp rewrite flush
wp rewrite structure '/%postname%'
Search and replace database
wp search-replace http://example.dev http://example.com
Run search/replace operation but dont save in database
wp search-replace http://example.dev http://example.com
Turn your production multisite database into a local dev database
wp search-replace --url=example.com example.com example.dev 'wp_*_options' wp_blogs
Search/replace to a SQL file without transforming the database
wp search-replace foo bar --export=database.sql
Display the WordPress version
wp core version
Update WordPress
wp core update
Update the WordPress database
wp core update-db
Update databases for all sites on a network
wp core update-db --network
Export database with drop query included
wp db export --add-drop-table
Import a MySQL database from a file or from STDIN
wp db import wordpress_dbase.sql