Skip to content

Instantly share code, notes, and snippets.

@zanematthew
Last active August 29, 2016 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zanematthew/f003f725f251ecbda245bd1627b103f0 to your computer and use it in GitHub Desktop.
Save zanematthew/f003f725f251ecbda245bd1627b103f0 to your computer and use it in GitHub Desktop.
Useful WP CLI commands
####
# Useful WP CLI commands
#
# All are presumed to be ran from the location of the `wp-config` file in
# question.
#
# Add an admin user
$ wp user create some-user-name my-email@my-site.com --role=administrator
# Add a superadmin for WP Networking
$ wp user create some-user-name my-email@my-site.com --role=superadmin
# Search for a value, and replace it, but do not execute on the database
$ wp search-replace 'foo.com' 'foo.dev' wp_options --dry-run
+------------+--------------+--------------+------+
| Table | Column | Replacements | Type |
+------------+--------------+--------------+------+
| wp_options | option_name | 0 | SQL |
| wp_options | option_value | 7 | PHP |
| wp_options | autoload | 0 | SQL |
+------------+--------------+--------------+------+
Success: 7 replacements to be made.
# Search for a value, and replace it, but do execute it on the database
$ wp search-replace 'foo.com' 'foo.com.dev' wp_option
+------------+--------------+--------------+------+
| Table | Column | Replacements | Type |
+------------+--------------+--------------+------+
| wp_options | option_name | 0 | SQL |
| wp_options | option_value | 7 | PHP |
| wp_options | autoload | 0 | SQL |
+------------+--------------+--------------+------+
Success: Made 7 replacements.
# Activate plugin
$ wp plugin activate some-plugin
# Deactivate plugins
$ wp plugin deactivate some-plugin
# List active plugins
$ wp plugin list
+----------------------------------------------+----------+-----------+---------+
| name | status | update | version |
+----------------------------------------------+----------+-----------+---------+
| plugin-a | active | none | 0.1.2 |
| some-other-plugin | active | available | 2.1.7 |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment