This section provides information on WP-CLI global parameters that you should be familiar with to help you use WP-CLI to develop and maintain your site.
The steps below use Terminus commands that require site and environment values. Before you begin, set the variables
$env in your terminal session to match your site name and the Dev environment. This allows the example commands to work in your local terminal:
export env=dev # Or a multidev test environment
WP-CLI will allows you to perform advanced operations on your WordPress site (including dropping your database).
Review the global parameters below to help you use WP-CLI to maintain your site.
--path=<path>- Specify the path to WordPress. WP-CLI will look upward from its current directory to attempt to find WordPress if this parameter isn't provided.
--url=<url>- Identify the request from a given URL. This argument specifies the target site in WordPress Multisites.
--user=<id|login|email>- Run the command as a particular user. WP-CLI commands are executed anonymously by default.
Each of these global parameters define the context under which the command is run. This provides important pre-condition statements to WordPress about how to understand the request.
Run the command below to learn more:
terminus wp $site.$env -- option get home [2015-11-25 02:42:12] [info] Running wp option get home on pantheon-demo cmd: 'option get home' flags: '' site: 'pantheon-demo' env: 'dev' https://pantheon-demo.pantheonsite.io
Review the information below to understand the output.
terminus wptells Terminus you want to execute a WP-CLI command.
option getis the command itself (docs).
homeis the key for the option you're requesting.
$envtell Terminus which site and environment to run the command in, respectively. These arguments can be provided automatically if you execute Terminus commands from a directory containing a
The first part of the output is Terminus telling you which command it's running, and where. The last line,
https://pantheon-demo.pantheonsite.io, is the response of
wp option get.
Here are more commands you may find helpful:
wp search-replace- Search for and replace specific strings in the database. Commonly used to correct references to platform domains. Use
--dry-runto perform a test run of the operation, and see how it will affect your database (developer docs).
wp media regenerate- Regenerate image thumbnails for one or more attachments (developer docs).
wp rewrite flush- Flush rewrite rules to ensure newly registered rules are stored in the database (developer docs).