Run WP-CLI Commands on Local WordPress Sites

If you work with WordPress locally, WP-CLI is usually the next tool you reach for. WP Staging CLI has you covered: the wp command runs any WP-CLI command inside the PHP container of one of your local sites and prints the result in your terminal.

Basic Usage

Put wpstaging wp in front of the command, and name the site first:

wpstaging wp mysite.local plugin list
wpstaging wp mysite.local option get siteurl

You do not install WP-CLI in the container or call docker exec yourself — WP Staging CLI runs it with the right user, path, and WordPress installation.

Query the Database

wpstaging wp mysite.local db query "SELECT COUNT(*) FROM wp_posts"

Target a Multisite Subsite

For networks, pass the subsite URL with WP-CLI’s --url flag:

wpstaging wp mynetwork.local --url=blog.mynetwork.local plugin list

Use It in Scripts

WP-CLI’s --format=json and WP Staging CLI’s own --json both parse cleanly, so a few lines of shell give you an inventory of every local site:

for site in $(wpstaging list --json | jq -r ".sites[].hostname"); do
  echo "$site: $(wpstaging wp $site core version)"
done

With a custom --env-path, point the command at environments stored outside the default folder:

wpstaging wp --env-path /custom/path mysite.local core version

Requirements

  • A registered WP Staging CLI license (Developer or Agency).
  • The site exists and its containers are running — start them with wpstaging start mysite.local.

Next Steps

Updated on October 29, 2026

Rene Hermenau

Author: Rene Hermenau

About the author: René Hermenau is the founder of WP STAGING. He works on WordPress backups, staging, migrations, database handling, and safe deployment workflows.