| layout | default |
|---|---|
| title | Command line interface for WordPress |
wp-cli is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs, create posts and much more.
- PHP >= 5.3
- WordPress >= 3.3
Via GIT:
git clone --recursive git://github.com/wp-cli/wp-cli.git ~/git/wp-cli cd ~/git/wp-cli sudo utils/dev-build
You can replace ~/git/wp-cli with whatever you want.
Via PEAR:
sudo pear channel-discover wp-cli.org/pear sudo pear install wpcli/wpcli
Via Debian Package:
Just download the php-wpcli_0.8-1_all.deb file and open it.
If the php command is not available, you can try finding an appropriate binary:
./utils/find-php
Then, create an environment variable called WP_CLI_PHP with the path found by find-php.
In a UNIX environment, you would do this by adding the following line to your .bashrc file:
WP_CLI_PHP=/path/to/php-binary
Go into a WordPress root folder:
cd /var/www/wp/
Typing wp should show you output similar to this:
Available commands:
wp blog create|delete
wp cache add|decr|delete|flush|get|incr|replace|set|type
wp comment create|delete|trash|untrash|spam|unspam|approve|unapprove|count|status|last
wp core download|config|is-installed|install|install-network|version|update|update-db
wp db create|drop|reset|optimize|repair|connect|cli|query|export|import
wp eval-file
...
See 'wp help <command>' for more information on a specific command.
Let's try to install the Hello Dolly plugin from wordpress.org:
wp plugin install hello-dolly
Output:
Installing Hello Dolly (1.5) Downloading install package from http://downloads.WordPress.org/plugin/hello-dolly.1.5.zip ... Unpacking the package ... Installing the plugin ... Plugin installed successfully.
On a multisite installation, you need to pass a --url parameter, so that wp-cli knows which site it's supposed to be operating on:
wp theme status --url=localhost/wp/test
If you have a subdomain installation, it would look like this:
wp theme status --url=test.example.com
If you're usually working on the same site most of the time, you can create a wp-cli.yml file in the root directory:
url: test.example.com
Then, you can call wp without the --url parameter again:
wp theme status
Adding commands to wp-cli is very easy. You can even add them from within your own plugin. You can find more information about adding commands in the Commands Cookbook on our Wiki.
Please share the commands you make, issue a pull request to get them included in wp-cli by default.
Commands:
- added
wp search-replacecommand - added
wp scaffoldcommand. props jmslbam and sebastiaandegeus - added
wp capcommand - added
wp user add-rolesubcommand - added
--roleparameter towp user remove-role - added
--idsparameter towp user list - added
--post__inparameter towp export - added
--strparameter to mostwp dbsubcommands - removed community commands (
wp total-cache,wp super-cache,wp sitemap) - made
wp post updateaccept multiple IDs - fixed incorrect exit code from
wp core is-installedin some cases - fixed
wp user import-csv. props danielbachhuber - fixed
wp theme update <theme> - fixed
wp plugin update <plugin>not reactivating the plugin
Internals:
- added support for
wp-cli.ymlconfig file - bypass full-page caching plugins
- disabled coloring when not in a TTY and added
--color/no-colorglobal parameters - added
--debugglobal parameter - added
wp --infoutility - added unit tests for
wp coresubcommands. props mwilliamson - Composer compatibility
Commands:
- added wp shell
- added
wp cache, props tollmanz - added
wp comment, props ozh - added
wp rewrite, props goldenapples - added
wp user import-csv, props danielbachhuber - added
wp user set-roleandwp user remove-role, props danielbachhuber - added
wp core is-installed - added
wp blog delete - added
wp post list - made
wp post deleteaccept a list of IDs - added
--dry-runoptionwp plugin update-all - improved
wp export, props danielbachhuber
Breaking changes:
- converted
wp plugin update --alltowp plugin update-all - converted
wp theme update --alltowp theme update-all - converted
wp generate poststowp post generate - converted
wp generate userstowp user generate - renamed
wp core install_networktowp core install-network - renamed
--pathoption to--dirinwp export
Internals:
- removed support for default subcommands
- introduced
@synopsisdocblock tag - introduced
@subcommanddocblock tag - introduced
@aliasdocblock tag - introduced
WP_CLI::add_man_dir()
Commands:
- added
wp postandwp post-meta - added
wp user-meta, props mwilliamson-red-gate - added
wp blog create, props kidfiction - added
wp export, props tott - added
wp theme installandwp theme update, props getsource - added
wp transient, props tollmanz - added
wp db optimizeandwp db repair, props getsource - added
wp db create,wp db dropandwp db reset - added
wp db import, props svaj - added
wp core install_network - added
wp core update_db, props mwilliamson-red-gate - added
--jsonoption to several subcommands - added
--networkoption towp plugin activate - fixed
wp plugin update
Internals:
- added
--requireglobal parameter - fixed "out of memory" error
- misc bugfixes and optimizations
- man pages (not in PEAR package)
Commands:
- added
wp user, props wopr42 - added
wp core download, props ericandrewlewis - added
wp core config - added
wp plugin update --all, props getsource
Internals:
- added
--url--pathand--userglobal parameters - various bugfixes
- added
wp evalandwp eval-file - added
wp export - added
wp core install - fixed
wp core update - added
--devflag towp plugin install - added
wp plugin uninstall - fixed
wp plugin installandwp plugin update
- added
wp sql - improved
wp option - pear installer
- added multisite support
- improved
wp pluginandwp theme - added
wp generate - added
wp core version - added
wp --version - added bash completion script
- initial release