О проекте

WP-CLI — это утилита командной строки для управления вашим сайтом на WordPress. При помощи WP-CLI вы можете обновлять, плагины, темы и многое другое без использвания веб-браузера.


  • UNIX-подобное окружение (OS X, Linux, FreeBSD, Cygwin)
  • PHP 5.3.2 или выше
  • WordPress 3.5.2 или выше


Чтобы начать пользоваться WP-CLI, скачайте сначала wp-cli.phar, используя wget или curl. Например:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Убедитесь, что это работает:

php wp-cli.phar --info

To be able to type just wp, instead of php wp-cli.phar, you need to make the file executable and move it to somewhere in your PATH. For example:

chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Now try running wp —info.

Upgrade using the same procedure.

If you’re using MAMP, you will probably get a MySQL error, because the php found in your PATH is not the same as the PHP used by MAMP. Here is one way to fix it.

More resources:

Getting Started with WP-CLI (includes video)
Alternative Install Methods
Tab completions
WP-CLI also comes with a tab completion script for Bash. Just download wp-completion.bash and source it from ~/.bash_profile:

source /FULL/PATH/TO/wp-completion.bash
(Don’t forget to run source ~/.bash_profile afterwards)

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 ‘ for more information on a specific command.
Let’s try to install the Hello Dolly plugin from wordpress.org:

wp plugin install hello-dolly

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
Adding commands to WP-CLI is as easy as creating a PHP class. See the Commands Cookbook for more info.

Please share the commands you make by adding them to the List of community commands.

Contributor list
Contributor guide