Global Parameters
Overview
Global parameters control execution context for any WP-CLI command. Use them to target the correct site, user, and runtime behavior before running operational commands.
Understanding Global Parameters
Control Execution Context
- Flags/options that can be applied to any WP-CLI command.
- They control environment, execution scope, and output.
- Example:
wp plugin list --path=/var/www/html --url=example.com --user=admin
Typical Users
- System Admins → Running commands on specific WordPress installs.
- Developers → Automating scripts with consistent paths/users.
- Agencies → Managing multiple client sites.
- Troubleshooters → Debugging plugin/theme issues.
Where to Apply Them
- At the end of any WP-CLI command.
- Example:
wp user list --url=mysite.com --format=json
- In config files (
~/.wp-cli/config.yml,wp-cli.yml).
Common Scenarios
- When working with:
- Multiple WordPress installations on the same server.
- Multisite networks.
- Script automation.
- Debugging and troubleshooting.
Why They Matter
- Control → Run commands exactly where/how you want.
- Automation → Scripts can apply to multiple sites.
- Debugging → Isolate issues by skipping plugins/themes.
- Consistency → Avoid mistakes when switching environments.
Basic Syntax
- General usage:
wp [command] [subcommand] [args] [--options] [--global-parameter]
Usage Prerequisites
Required Tools
- WP-CLI installed (
wp --info). - At least one WordPress installation.
- SSH or terminal access.
Preparation
- Navigate to or know your WordPress install path.
- Have at least one admin user for
--userparameter. - For debugging, note installed plugins/themes.
Command Usage Patterns
| Parameter | Description | Example |
|---|---|---|
--path=PATH | Path to WordPress installation | wp plugin list --path=/var/www/site |
--url=URL | Target site URL (multisite or multiple installs) | wp option get home --url=site2.com |
--user=ID_OR_LOGIN_OR_EMAIL | Run command as a specific user context | wp post list --user=editor |
--skip-plugins[=PLUGIN] | Skip all plugins or specific ones | wp plugin update --all --skip-plugins=woocommerce |
--skip-themes[=THEME] | Skip all themes or specific ones | wp theme status --skip-themes |
--require=PATH | Load an additional PHP file before command execution | wp --require=custom.php plugin list |
--quiet | Suppress output | wp plugin update --all --quiet |
--debug[=GROUP] | Show debug info (optional group: bootstrap, commandfactory, etc.) | wp plugin list --debug |
Best Practices
| Benefit | Explanation | Impact |
|---|---|---|
| Precision | Run commands on exact site/path | Avoid mistakes |
| Debugging | Identify plugin/theme issues quickly | Faster troubleshooting |
| Automation | Script commands across sites/users | Saves time |
| Flexibility | Skip elements, silence output, require files | More control |
| Safety | Preview/debug before applying changes | Reduced risk |
Real-World Scenarios
Example 1: Target a Specific Site Path
wp core version --path=/var/www/client1
- Use Case: Multiple WordPress installs on one server.
Example 2: Run Command on a Specific URL (Multisite)
wp option get siteurl --url=blog.example.com
- Use Case: Multisite admin checking subsites.
Example 3: Run as Another User
wp post create post.txt --user=editor
- Use Case: Testing role permissions.
Example 4: Skip Specific Plugin
wp theme activate twentytwentyfour --skip-plugins=security-plugin
- Use Case: Theme activation while ignoring interfering plugin.
Example 5: Debugging
wp plugin list --debug
- Use Case: Identify load sequence and potential issues.
Example 6: Quiet Mode
wp plugin update --all --quiet
- Use Case: Cron jobs or automated scripts (no spammy output).
Quick Reference
Syntax
wp [command] [subcommand] [args] [--options] [--global-parameters]
Common Parameters
--path=PATH→ Specify WordPress install directory.--url=URL→ Target site in multisite or multiple installs.--user=ID_OR_LOGIN_OR_EMAIL→ Run as specific user.--skip-plugins[=PLUGIN]→ Skip all or one plugin.--skip-themes[=THEME]→ Skip all or one theme.--quiet→ Silence output.--debug[=GROUP]→ Enable debug info.
At a Glance
| Topic | Key Takeaways |
|---|---|
| Purpose | Global parameters modify command scope & execution |
| Typical users | Sysadmins, devs, agencies, troubleshooters |
| Execution context | Anywhere: local, SSH, scripts |
| Common scenarios | Multiple installs, multisite, debugging, automation |
| Value | Precision, flexibility, control |
| Basic usage | Append flags like --path, --url, --user |
| Prerequisites | WP-CLI installed, WordPress path, admin user |
| Benefits | Precision, automation, safety, debugging |
| Core Params | --path, --url, --user, --skip-plugins, --skip-themes, --quiet, --debug |
Next Steps
- Continue to WP-CLI Workflow to understand bootstrap and execution flow.
- Use these flags in Core Commands and Database Operations.