Skip to main content

WP-CLI Global Parameters

Review important WP-CLI global parameters.

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 $site and $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 site=yoursitename
export env=dev # Or a multidev test environment

Getting Started With WP-CLI

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.

  1. 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'
  2. Review the information below to understand the output.

  • terminus wp tells Terminus you want to execute a WP-CLI command.

  • option get is the command itself (docs).

  • home is the key for the option you're requesting.

  • $site and $env tell 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 .env file.

  • The first part of the output is Terminus telling you which command it's running, and where. The last line,, 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-run to 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).

More Resources