Skip to content
Advertisement

Add product category in woocommerce archive/shop page

I’m trying to add the product category inside the product card in the woocommerce archive page. Right now it shows “Thumbnail” “Title” “Price” and “Add to cart button”.

I’m using this function which should work if the variable “product” is set to the current product displayed.

My Question: Is there a way to get the queried Product in this variable?

Any help is appreciated.

JavaScript

Advertisement

Answer

JavaScript

You need to add the line global $product as shown above. $product is an instance of WC_Product, I believe Woocommerce uses WordPress’ the_post() functionality under the hood to set this variable but I’m not 100% sure.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement