I'm working on a Woocommerce shop that has its products organized by parent categories such as Brand, Color, Size, etc. Each of these top-level categories has a number of subcategories: for example, subcategories of Color include Red, Blue, Pink, etc.
Client wants to display each product's brand and size (the products are shoes) below each product thumbnail in the grid/loop view on the front and archive pages.
Each product is only one brand, but might have multiple sizes available.
So essentially, I need to know if there's a way to display the title of only a specific subcategory for a single product, like so:
[Product Thumbnail here]
[Price info here]
Brand: Nike
Size(s): 8, 8.5, 9
I just need the subcat titles, not links. I know the solution to this will likely involve calling the get_terms() function in content-product.php, but I haven't been able to figure out how to list only specific subcategories for a product.
The code I'm looking for will basically say:
If this product is in the Brand category,
Then show its subcategory.
If this product is in the Size category,
Then show its subcategories.