Skip to main content

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

  1. Navigate to or know your WordPress install path.
  2. Have at least one admin user for --user parameter.
  3. For debugging, note installed plugins/themes.

Command Usage Patterns

ParameterDescriptionExample
--path=PATHPath to WordPress installationwp plugin list --path=/var/www/site
--url=URLTarget site URL (multisite or multiple installs)wp option get home --url=site2.com
--user=ID_OR_LOGIN_OR_EMAILRun command as a specific user contextwp post list --user=editor
--skip-plugins[=PLUGIN]Skip all plugins or specific oneswp plugin update --all --skip-plugins=woocommerce
--skip-themes[=THEME]Skip all themes or specific oneswp theme status --skip-themes
--require=PATHLoad an additional PHP file before command executionwp --require=custom.php plugin list
--quietSuppress outputwp plugin update --all --quiet
--debug[=GROUP]Show debug info (optional group: bootstrap, commandfactory, etc.)wp plugin list --debug

Best Practices

BenefitExplanationImpact
PrecisionRun commands on exact site/pathAvoid mistakes
DebuggingIdentify plugin/theme issues quicklyFaster troubleshooting
AutomationScript commands across sites/usersSaves time
FlexibilitySkip elements, silence output, require filesMore control
SafetyPreview/debug before applying changesReduced 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

TopicKey Takeaways
PurposeGlobal parameters modify command scope & execution
Typical usersSysadmins, devs, agencies, troubleshooters
Execution contextAnywhere: local, SSH, scripts
Common scenariosMultiple installs, multisite, debugging, automation
ValuePrecision, flexibility, control
Basic usageAppend flags like --path, --url, --user
PrerequisitesWP-CLI installed, WordPress path, admin user
BenefitsPrecision, automation, safety, debugging
Core Params--path, --url, --user, --skip-plugins, --skip-themes, --quiet, --debug

Next Steps