I have a product attribute called "color" and when I am on the archive page (e.g. color=blue) I want to display a list of all the parent product categories that contain products with that attribute, color=blue.
I tried using get_queried_object_id() to get the archive term (blue), in conjunction with get_terms(), however I couldn't figure it out. I'd like to reiterate that I want to retrieve the list of terms and not the posts.
If anyone can lead me in the right direction, I'd appreciate it!
This question seems similar to what I want, however it uses wpdb, and want to use a regular query.
I was tried doing something like this, to get a list of all posts that are in both taxonomies (pa_color and product category), but I am not sure how to get a list of just categories.
$current_color = get_queried_object_id();
$query = new WP_Query( array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'pa_color',
'field' => 'term_id',
'terms' => $current_color,
'operator' => 'AND'
),
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $cats
)
)
) );