0

I have been searching and found a function that will display all WooCommerce product categories, but I am looking for a function that will retrieve single product category name by giving product category ID. Raw product category name, no url, no thumbnail, nothing.

I need to use it in my template file.

For instance: Category Name for 'Bags' has id '15'

I need something like this:

showCategoryName(15);

RESULT: Bags

Thanks

1 Answer 1

0

You can use WP native functions like get_terms:

function woocommerceCategoryName($id){
    $term = get_term( $id, 'product_cat' );
    return $term->name;        
}

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.