Looper with Woocommerce Product Atrributes

I need to build a gallery on the PDP that shows items in the same location. I have Location set as a Woocommerce attribute. How do I set the looper to pull in products with the matching location? I am working on the “Woocommerce Single” page template in Cornerstone.

Hello @tylerlukey,

Thanks for writing in! We can recommend that you use the Looper Provider Query String. But first, you must define the query argument. For example;

$query_args = array(
    'post_type' => 'product',
    'tax_query' => array(
        array(
            'taxonomy' => 'pa_location',
            'field'    => 'slug',
            'terms'    => 'new-york',
        ),
    ),
);

Using the http_build_query() function, you can get:

post_type=product&tax_query%5B0%5D%5Btaxonomy%5D=pa_location&tax_query%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Bterms%5D=new-york

I used “New York” as the location in my example above.

Hope this makes sense.