Answer the question
In order to leave comments, you need to log in
How to write a condition for products in a specific Woocommerce category?
There is a task to display a certain block on the pages of a specific category of Woocommerce products and on the pages of all products belonging to this category.
There is is_product_category() to define a category, and for products you need something like in_product_category() similar to posts, but there is no such tag. How to write such a condition correctly?
Answer the question
In order to leave comments, you need to log in
$cats = array(91,22)
if ( has_term($cats, 'product_cat', $product_id ) ) {
// выводим что нужно
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question