I want to get all products of category by category name (slug). Сategory has no parents or children. I wrote my code according to this answer. My code:
<?php $args = [ 'post_type' => 'product', 'posts_per_page' => -1, 'product_cat' => 'pyvo-v-pliashkah' ]; $products = new WP_Query($args); wp_reset_query(); echo "<pre>"; print_r($products->posts); ?>
But instead products of "pyvo-v-plyashkah" category I get all products of all categoryes. Where is my mistake?