I need to show content in a div in Woocommerce only if a certain product category is selected
I’m editing archive-product.php file and have added
<?php
if(in_category('cg-odobreno')){
?>
<div>
/**/
</div>
<?php } ?>
This in_category part is related to actual categories not product categories if I’m not mistaken. How can I select a product category?
2
Answers
You’re looking for is_category. More @ https://developer.wordpress.org/reference/functions/is_category/
You can use slugs, names or ids.
In_category() will use in case if you want to check that category exists in particular post/product
In your case you can do it with is_category().