Can I retrieve woocommerce product category name by ID?

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


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 – user3137901 Jun 18 '14 at 19:53
  • oh sorry, forgot the taxonomy name woocommerce uses. – Milo Jun 18 '14 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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