Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author DecomTeam

    (@decomteam)

    hi @haleekalevitch you can create category then exclude that category using a action woocommerce_product_query inside your functions.php file.

    Gist: Here is a code you will need

    add_action( 'woocommerce_product_query', 'giftable_custom_pre_get_posts_query' );
    function giftable_custom_pre_get_posts_query( $exclude_query ) {
    	if( is_shop() || is_page('or-some-special-page') ) { // set conditions here
    	    $tax_query = (array) $exclude_query->get( 'tax_query' );
    	    $tax_query[] = array(
    	           'taxonomy' => 'product_cat',
    	           'field'    => 'slug',
    	           'terms'    => array( 'exclude', 'gifts' ), // excluded categories
    	           'operator' => 'NOT IN'
    	    );
    	
    	    $exclude_query->set( 'tax_query', $tax_query );
    	}
    }
    Thread Starter haleekalevitch

    (@haleekalevitch)

    It is still showing the category header at the top of the shop page – I do not want them to even know their is a “gifts” category

    Plugin Author DecomTeam

    (@decomteam)

    dear @haleekalevitch you can use many actions/hooks to hide all things in WooCommerce (menus, titles, headings, listings) – thats theme customisation part

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide Gift Product Category from Shop’ is closed to new replies.