Letting WooCommerce’s REST API find a product attribute by slug

My proposed WooCommerce fix lets developers ask the REST API for one product attribute by its slug, such as pa_color, and get just that attribute back. With it, integrations that sync catalogues or build filters don’t have to download every attribute to find one. PR #69318 is open as a draft; the screenshots below show…

My proposed WooCommerce fix lets developers ask the REST API for one product attribute by its slug, such as pa_color, and get just that attribute back. With it, integrations that sync catalogues or build filters don’t have to download every attribute to find one. PR #69318 is open as a draft; the screenshots below show the patch applied.

The problem

A request for /wc/v3/products/attributes?slug=pa_color should return just the Color attribute. Instead it returns every attribute in the store, and the X-WP-Total header counts all of them. The category and tag endpoints already honour slug, so the attributes endpoint was the odd one out. The endpoint never registered a slug parameter, so the controller ignores it. The issue was reported in April 2021, and trunk still behaved this way in October 2026. Issue #29625 ↗

The fix

The patch adds an optional slug parameter to the v3 endpoint. It takes one slug or a list, and the pa_ prefix is optional, so pa_color, color and Color all find the same attribute. That is the same rule WooCommerce applies when you create an attribute, so the slug you sent on create works for lookup too. The filter runs over the attribute list WooCommerce already caches, so it adds no database queries. I changed only v3, the current version, so integrations still on v1 or v2 see no difference. PR #69318 ↗

I reproduced the before and after with wp-env on WooCommerce 11.1.2 and WordPress 7.1.2. The new unit tests fail on trunk and pass with the patch, and all 918 REST API controller tests pass with it. I did not test multisite. As of 2 October 2026, the PR is an open draft. Its CI is waiting for a maintainer to approve the workflow runs, and it still needs review.

Before and after

JSON response listing three product attributes, Color, Material and Size, with Material and Size bracketed as not requested
Before: asking for slug=pa_color returns all three attributes.
JSON response listing only the Color attribute, with its pa_color slug boxed
After: the same request returns only Color.

See the PR ↗ · Issue ↗


More from the journal

The latest news on sustainability, knitwear and clothing care guides.