I just inherited a woocommerce project and I need to change the home page to only show specific brands. They set up a Product-Data => Attribute => pa_brand.
If I print pa_brand array it show me this:
Array
(
[0] => stdClass Object
(
[term_id] => 1134
[name] => Name Brand
[slug] => name-brand
[term_group] => 0
[term_taxonomy_id] => 1134
[taxonomy] => pa_brand
[description] =>
[parent] => 0
[count] => 68
[object_id] => 3385
[filter] => raw
)
)
I'm under the impression I would be able to use the pa_brand to filter the query using one of the key value pairs, preferably the slug, but I'm unsure how to do this. None of the examples I've found has an object, just string results:
$args = array(
'post_type' => array('product', 'product_variation'),
'posts_per_page' => 3,
'orderby' => 'rand',
'meta_query' => array(
array(
'key' => 'pa_brand',
'value' => array('slug' => 'brand-name'),
'compare' => '=',
),
array(
'key' => '_stock_status',
'value' => 'instock',
'compare' => '='
)
)
);
I've tried a lot of variations on this and none of them work. Any suggestions?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire