I'm trying to query WooCommerce products based on a specific attribute. For example, I set up an attribute called
colour, with possible values of
I want to select all products with a colour value of "green", so I query using the following:
$args = array( 'post_type' => 'product', 'meta_query' => array( array( 'key' => 'pa_colour', 'value' => 'green', 'compare' => '=' ) ) ); query_posts($args);
I understand it that WooCommerce attributes are preceded with
pa_, but any variant of the attribute name is just as unsuccessful. Where am I going wrong? Is it possible to query attributes in this way?