A
A
Alexander Kokorin2021-02-01 19:54:55
WooCommerce
Alexander Kokorin, 2021-02-01 19:54:55

How to display a block in a product from a specific category?

Good afternoon, forum users.
There is a block on the product page that should be in the ID=20 category, but not in the ID=28 category.
Please tell me how to implement it. I searched the entire Internet, and the forum, did not find anything like it, maybe of course I looked inattentively. In general, did no one come across such a thing, I do not believe it.

Tried through:

<?php
if (! is_product_category( array ( '28' ) )) {
echo '<p>Кол-во упаковок:</p>';
}
?>


Naturally, this didn't work, because I realized that is_product_category on the product page always returns false.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2021-02-01
@kokorinleks

Here is the link to the article - https://rudrastyh.com/woocommerce/if-product-in-ca...
You need to check if this product belongs to category X

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question