I’m trying to query custom post type of products and all the tags inside the $terms variable. I want this to work whether there is a single tag or multiple tags. The tags are not unique to the business types but general post tags
here is what I have so. I’m pretty sure the issue is in the tax_query section
$terms = get_field('tags_for_products');
if ($terms) {
if (!is_array($terms)) {
$terms = array($terms);
}
}
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'orderby' => 'rand',
'tax_query' => array(
array(
'taxonomy' => 'tag',
'field' => 'slug',
'terms' => $terms,
),
),
);
$products = new WP_Query($args);
this is the current array inside the $terms variable.
Array ( [0] => WP_Term Object ( [term_id] => 98 [name] => Hats [slug] => hats [term_group] => 0 [term_taxonomy_id] => 98 [taxonomy] => post_tag [description] => [parent] => 0 [count] => 0 [filter] => raw ) [1] => WP_Term Object ( [term_id] => 96 [name] => Hoodie [slug] => hoodie [term_group] => 0 [term_taxonomy_id] => 96 [taxonomy] => post_tag [description] => [parent] => 0 [count] => 0 [filter] => raw ) )