How to remove products from a particular taxonomy product listing using wordpress loop.

  • 0

You need to specify the category, that you want to remove the products from listing, in “tax_query”.

$args = array(
‘post_type’ => ‘product’,
‘posts_per_page’ => 20,
‘tax_query’=>array(array(
‘taxonomy’ => ‘product_cat’,
‘field’ => ‘slug’,
‘terms’ => array( ‘gift-product’ ), // specify the product here
‘operator’ => ‘NOT IN’
)) );

Here we can query all products except product with category “gift-product”.

You need to specify the category, that you want to remove the products from listing, in “tax_query”. $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 20, ‘tax_query’=>array(array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array( ‘gift-product’ ), // specify the product here ‘operator’ => ‘NOT IN’ )) ); Here we can query all products…

You need to specify the category, that you want to remove the products from listing, in “tax_query”. $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 20, ‘tax_query’=>array(array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array( ‘gift-product’ ), // specify the product here ‘operator’ => ‘NOT IN’ )) ); Here we can query all products…