How can I exclude a product_cat from a custom loop
-
Hey guys, looking for some help excluding a single category from a custom product loop I’m doing. Essentially I have a called called ‘frames’ with ID ‘2018’. Any products assigned to this category, I wish to exclude within my loop.
Here’s my arguments:
$args = array(
‘post_type’ => ‘product’,
‘posts_per_page’ => 4,
‘orderby’ =>’date’,
‘order’ => ‘DESC’,
‘post_status’ => ‘publish’,
‘product_cat’ => ‘-frames’
);
$loop = new WP_Query( $args );I’m assuming that ‘product_cat’ is a custom parameter created by WooCommerce, and this can be used to specify a category to only get products from. You’ll notice I’m trying to exclude frames, but this doesn’t seem to work.
Any help would be greatly appreciated, thanks, james.
- The topic ‘How can I exclude a product_cat from a custom loop’ is closed to new replies.