I’m trying to pull all products located within a certain category slug.
I’ve tried the following, however both return every product in the store.
$products = wc_get_products( array( 'category' => array( 'Sony' ) ));
and
$productlist = wp_query(array( 'post_type' => 'product', 'product_cat' => 'Sony'));
Any pointers would be much appreciated.
3
Answers
Try this code
Try This:
Try with this and replace ENTER_CATEGORY with slug name or use simple ‘terms’ => ‘slug/categoryname’