How to exclude the particular category from the woocommerce plugin? (1 post)

  1. vicky081
    Posted 3 years ago #

    add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
    function custom_pre_get_posts_query( $q ) {
    if ( ! $q->is_main_query() ) return;
    if ( ! $q->is_post_type_archive() ) return;
    if ( ! is_admin() ) {
    $q->set( 'tax_query', array(array(
    'taxonomy' => 'product_cat',
    'field' => 'slug',
    'terms' => array( 'membership' ), // Don't display products in the membership category on the shop page
    'operator' => 'NOT IN'
    remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' );

    I used the above code to exclude the membership category in the shop page. Its working on the shoppage but it display in the homepage i need to know how to exclude the particular category in all those page . Basic idea is to be download the products only for the membership. I added the membership as the seperate product category , Also i exclude that category from the shop page but it displaying in the homepage . I don't how to do this in the woocommerce plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic