Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

WooCommerce get taxonomy term by another taxonomy term WordPress

For example I have a WooCommerce product, and it has two taxonomies:


product_cat // category of product
product_brand // brand of product


I want to create a list of categories for specific brand. So when user visits brand page he can view it as a tree (like on [[LINK href="http://www.zappos.com/rieker"]]http://www.zappos.com/rieker[[/LINK]] )

I can get list of categories like so:

get_terms('product_cat');

But how can I filter them to display only categories that have products with specific brand? And is it possible to display number of items in each category in a fast way?

Thank you!

Answers (2)

2013-04-19

Daniel Yoen answers:

why you not use hierarchical taxonomies ?


Daniel Yoen comments:

I think, you can't do that, because no relations, but, you can use hierarchical taxonomies, llike this :

Category-1
Brand-1
Brand-2
Brand-3
Category-2
Brand-1
Brand-2
Brand-3


kihghil comments:

This is not an option, unfortunately, as same brand can have different parent category.

2013-04-20

Yakir Sitbon answers:

Hi kihghil.

How you setup your product? And how you want filter by brand? Is it custom page for that or what?


kihghil comments:

Hi,

Product post type simply has two taxonomies - category and brand.


Yakir Sitbon comments:

OK, how you want to filter? How i can know which brand you use?