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

  1. snaptin
    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(
            'key' => 'pa_colour',
            'value' => 'green',
            'compare' => '='

    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?


  2. Kamlesh
    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