WordPress.org

Forums

WooCommerce - excelling eCommerce
Query WooCommerce Products based on Attribute (2 posts)

  1. snaptin
    Member
    Posted 1 year ago #

    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/

  2. Kamlesh
    Member
    Posted 1 year ago #

    i also want to know this.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic