Get the category from an ID of a product?

Since the question is tagged woocommerce, i’m assuming that it’s a product CPT created by woocommerce wordpress plugin. This answer doesn’t apply if that’s not the case.

The products categories is not normal categories, they are a custom taxonomy created specifically for products which is just labeled as “Categories”.

You should go through the woocommerce documentation to find some function that would do this for you, if you don’t find anything you can try an alternative solution. For that, first you should know the name of the taxonomy. You can copy it from inside the url in your browser when you visit categories edit screen in the backend. Then you can use wp_get_post_terms to get the terms.

Leave a Comment