Wp Cli



WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installations and much more, without using a web browser.

Ongoing maintenance is made possible by:

Cli

The current stable release is version 2.4.0. For announcements, follow @wpcli on Twitter or sign up for email updates. Check out the roadmap for an overview of what’s planned for upcoming releases.

Quick links: Using | Installing | Support | Extending | Contributing | Credits

Using

WP-CLI provides a command-line interface for many actions you might perform in the WordPress admin. For instance, wp plugin install --activate (doc) lets you install and activate a WordPress plugin:

A new premier sponsor has come forward and is added to the list of generous companies that sponsor the WP-CLI WP-CLI WP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. Using WP-CLI, you could easily connect the server directly to the WordPress Theme Repository and import the theme in a matter of moments. As you can guess, WordPress CLI installation and theme activation processes are really simple. You can also update and delete themes through WP-CLI as well.

The WP-CLI is a tool that enables you to interact with your WordPress site directly by using commands in a text-based interface. It’s also very comprehensive, featuring a wide variety of potential commands. Almost anything you can do on the back end of your site, you can do much faster using the WP-CLI.

WP-CLI also includes commands for many things you can’t do in the WordPress admin. For example, wp transient delete --all (doc) lets you delete one or all transients:

For a more complete introduction to using WP-CLI, read the Quick Start guide. Or, catch up with shell friends to learn about helpful command line utilities.

Wp Cli Search Replace

Already feel comfortable with the basics? Jump into the complete list of commands for detailed information on managing themes and plugins, importing and exporting data, performing database search-replace operations and more.

Wp Cli Export

Installing

Downloading the Phar file is our recommended installation method for most users. Should you need, see also our documentation on alternative installation methods (Composer, Homebrew, Docker).

Before installing WP-CLI, please make sure your environment meets the minimum requirements:

  • UNIX-like environment (OS X, Linux, FreeBSD, Cygwin); limited support in Windows environment
  • PHP 5.6 or later
  • WordPress 3.7 or later. Versions older than the latest WordPress release may have degraded functionality

Once you’ve verified requirements, download the wp-cli.phar file using wget or curl:

Next, check the Phar file to verify that it’s working:

To use WP-CLI from the command line by typing wp, make the file executable and move it to somewhere in your PATH. For example:

If WP-CLI was installed successfully, you should see something like this when you run wp --info:

Updating

You can update WP-CLI with wp cli update (doc), or by repeating the installation steps.

If WP-CLI is owned by root or another system user, you’ll need to run sudo wp cli update.

Want to live life on the edge? Run wp cli update --nightly to use the latest nightly build of WP-CLI. The nightly build is more or less stable enough for you to use in your development environment, and always includes the latest and greatest WP-CLI features.

Tab completions

WP-CLI also comes with a tab completion script for Bash and ZSH. Just download wp-completion.bash and source it from ~/.bash_profile:

Don’t forget to run source ~/.bash_profile afterwards.

If using zsh for your shell, you may need to load and start bashcompinit before sourcing. Put the following in your .zshrc:

Support

WP-CLI’s maintainers and contributors have limited availability to address general support questions. The current version of WP-CLI is the only officially supported version.

When looking for support, please first search for your question in these venues:

If you didn’t find an answer in one of the venues above, you can:

  • Join the #cli channel in the WordPress.org Slack to chat with whomever might be available at the time. This option is best for quick questions.
  • Post a new thread in the WordPress.org support forum and tag it ‘WP-CLI’ so it’s seen by the community.

GitHub issues are meant for tracking enhancements to and bugs of existing commands, not general support. Before submitting a bug report, please review our best practices to help ensure your issue is addressed in a timely manner.

Please do not ask support questions on Twitter. Twitter isn’t an acceptable venue for support because: 1) it’s hard to hold conversations in under 280 characters, and 2) Twitter isn’t a place where someone with your same question can search for an answer in a prior conversation.

Remember, libre != gratis; the open source license grants you the freedom to use and modify, but not commitments of other people’s time. Please be respectful, and set your expectations accordingly.

Wp CliWp cli commands

Extending

A command is the atomic unit of WP-CLI functionality. wp plugin install (doc) is one command. wp plugin activate (doc) is another.

WP-CLI supports registering any callable class, function, or closure as a command. It reads usage details from the callback’s PHPdoc. WP_CLI::add_command() (doc) is used for both internal and third-party command registration.

WP-CLI comes with dozens of commands. It’s easier than it looks to create a custom WP-CLI command. Read the commands cookbook to learn more. Browse the internal API docs to discover a variety of helpful functions you can use in your custom WP-CLI command.

Contributing

We appreciate you taking the initiative to contribute to WP-CLI. It’s because of you, and the community around you, that WP-CLI is such a great project.

Wp cli wordpress

Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Read through our contributing guidelines in the handbook for a thorough introduction to how you can get involved. Following these guidelines helps to communicate that you respect the time of other contributors on the project. In turn, they’ll do their best to reciprocate that respect when working with you, across timezones and around the world.

Leadership

Wp Cli Path

WP-CLI has one project maintainer: schlessera.

On occasion, we grant write access to contributors who have demonstrated, over a period of time, that they are capable and invested in moving the project forward.

Read the governance document in the handbook for more operational details about the project.

Wp Client

Credits

Wp Cli Rest

Besides the libraries defined in composer.json, we have used code or ideas from the following projects:

  • Drush for… a lot of things
  • wpshell for wp shell
  • Regenerate Thumbnails for wp media regenerate
  • Search-Replace-DB for wp search-replace
  • WordPress-CLI-Exporter for wp export
  • WordPress-CLI-Importer for wp import
  • wordpress-plugin-tests for wp scaffold plugin-tests

Installs one or more plugins.

OPTIONS OPTIONS

Cli
<plugin|zip|url>…
One or more plugins to install. Accepts a plugin slug, the path to a local zip file, or a URL to a remote zip file.
[--version=<version>]
If set, get that particular version from wordpress.org, instead of the stable version.
[--force]
If set, the command will overwrite any installed version of the plugin, without prompting for confirmation.
[--activate]
If set, the plugin will be activated immediately after install.
[--activate-network]
If set, the plugin will be network activated immediately after install

EXAMPLES EXAMPLES

Wp Cli Ssh

GLOBAL PARAMETERS GLOBAL PARAMETERS

These global parameters have the same behavior across all commands and affect how WP-CLI interacts with WordPress.

ArgumentDescription
--path=<path>Path to the WordPress files.
--url=<url>Pretend request came from given URL. In multisite, this argument is how the target site is specified.
--ssh=[<scheme>:][<user>@]<host|container>[:<port>][<path>]Perform operation against a remote server over SSH (or a container using scheme of “docker”, “docker-compose”, “vagrant”).
--http=<http>Perform operation against a remote WordPress installation over HTTP.
--user=<id|login|email>Set the WordPress user.
--skip-plugins[=<plugins>]Skip loading all plugins, or a comma-separated list of plugins. Note: mu-plugins are still loaded.
--skip-themes[=<themes>]Skip loading all themes, or a comma-separated list of themes.
--skip-packagesSkip loading all installed packages.
--require=<path>Load PHP file before running the command (may be used more than once).
--[no-]colorWhether to colorize the output.
--debug[=<group>]Show all PHP errors and add verbosity to WP-CLI output. Built-in groups include: bootstrap, commandfactory, and help.
--prompt[=<assoc>]Prompt the user to enter values for all command arguments, or a subset specified as comma-separated values.
--quietSuppress informational messages.

Wp Cli Change Password

Command documentation is regenerated at every release. To add or update an example, please submit a pull request against the corresponding part of the codebase.