Can I retrieve woocommerce product category name by ID?

Not thumbnail, not the URL, not the Sub-categories, just raw Category name.

1 Answer 1


Use get_term_by:

$id = 42;
if( $term = get_term_by( 'id', $id, 'product_cat' ) ){
    echo $term->name;
  • 1
    Worked great! Thanks. It wasn't working before, but I changed 'product_category' to 'product_cat' and it worked Jun 18, 2014 at 19:53
  • oh sorry, forgot the taxonomy name woocommerce uses.
    – Milo
    Jun 18, 2014 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.