Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Exclude Products From a Particular Category on The Shop Page in WooCommerce

In this tutorial, I am going to share how to exclude products from a particular category on the shop page in WooCommerce store. If you want to hide products from the specific category in your WooCommerce store.

Exclude products from a particular category on the shop page

Copy the below code and add at the end of the functions.php file.

get( 'tax_query' );

    $tax_query[] = array(
           'taxonomy' => 'product_cat',
           'field' => 'slug',
           'terms' => array( 'clothing' ), 
           // Don't display products in the clothing category on the shop page.
           'operator' => 'NOT IN'
    );


    $q->set( 'tax_query', $tax_query );

}

add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );

?>

Conclusion

I hope this tutorial helps you, if you have any questions regarding WordPress, then feel free to put your comments in below comment section. Do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.

The post Exclude Products From a Particular Category on The Shop Page in WooCommerce appeared first on FreeWebMentor.



This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here

Share the post

Exclude Products From a Particular Category on The Shop Page in WooCommerce

×

Subscribe to Programming Blog Focused On Web Technologies

Get updates delivered right to your inbox!

Thank you for your subscription

×