Skip to content

Add --site-path filter to wp site list to avoid conflict with global --path#595

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-wp-site-list-path-filter
Draft

Add --site-path filter to wp site list to avoid conflict with global --path#595
Copilot wants to merge 3 commits intomainfrom
copilot/fix-wp-site-list-path-filter

Conversation

Copy link
Contributor

Copilot AI commented Mar 15, 2026

wp site list documents path as a filterable field, but --path is a global WP-CLI parameter (WordPress install directory), so it's silently consumed before reaching the command in normal usage — making path-based filtering impossible without strict args mode.

Changes

  • src/Site_Command.php: Keeps path in the generic $site_cols auto-mapping loop (so --path continues to work as a field filter when WP_CLI_STRICT_ARGS_MODE=1 is set), and adds explicit handling for --site-path=<path>, which maps to the path column in wp_blogs.
  • Docblock: Documents --site-path and notes that --path conflicts with the global parameter in normal usage, recommending --site-path instead.
  • features/site.feature: Adds a Behat scenario asserting --site-path correctly filters results.

Usage

# Works in strict args mode (WP_CLI_STRICT_ARGS_MODE=1)
wp site list --path=/first/

# Works in all modes (recommended)
wp site list --site-path=/first/
Original prompt

This section details on the original issue you should resolve

<issue_title>Unable to use wp site list to filter sites by path</issue_title>
<issue_description>## Bug Report

The wp site list command supports filtering to specific fields, such as domain:
wp site list --domain=wordpress.org
and the documentation suggests it can filter to the path, but the parameter conflicts with the global --path parameter.

The code seems to suggest it's possible too:
https://github.com/wp-cli/entity-command/blob/master/src/Site_Command.php#L558-L563

It should be possible to list sites by their path component somehow, eg: wp site list --field-path=/support/

Let us know what environment you are running this on

OS:	Linux 4.9.0-5-amd64 wp-cli/entity-command#1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04) x86_64
PHP version:	7.2.28
WP-CLI version:	2.4.0

</issue_description>

Comments on the Issue (you are @copilot in this section)

@dd32 Thanks @ocean90! I still feel this is a bug and there should at least be a prefixed variant of the args if strict mode is never going to be enforced.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix filtering by path in wp site list command Add --site-path filter to wp site list to avoid conflict with global --path Mar 15, 2026
Copilot AI requested a review from swissspidy March 15, 2026 13:24
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI requested a review from swissspidy March 15, 2026 15:51
@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:network Related to 'network' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to use wp site list to filter sites by path

2 participants