I am creating a e-commerce website using woo commerce. I am struggling with a code that how to display the category name of the product using category id in woocommerce?.
In wordpress its easy to display the category name by id as get_the_category_by_id(3)
. So that it display the name of the id 3.
By the same way how to display the category name by id in woocommerce?
Try this function to get product category name
Hope this will be useful.
you can use something like this
Please, let me know whether it helps.
You can use wp_get_post_terms to get category id of any product like this :
I am just fetching id’s of categories assigned to the particular product, You can fetch name also.
Hope this will be useful.