Support » Plugin: WooCommerce » Query WooCommerce Products based on Attribute

  • 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 red or green.

    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?

    http://wordpress.org/plugins/woocommerce/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Query WooCommerce Products based on Attribute’ is closed to new replies.