• Hi,
    I need to hide some product’s from page, where is uses tags
    [product_category per_page=”8″ columns=”4″ category=”watches”]
    For example I set tag “notshow’ in Woocommerce for product, and it must don’t show on my homepage, where I use shortcode [product_category]
    I did it by adding this to functions.php

    function se_customize_product_shortcode( $args, $atts ) {
        if ( is_page( 'home' ) ) {
            $args['tax_query'] = array(
                array(
                    'taxonomy' => 'product_tag',
                    'field'    => 'slug',
                    'terms'    => array( 'notshow' ),
                    'operator' => 'NOT IN'
                )
           );
        }
    
        return $args;
    }
    add_filter( 'woocommerce_shortcode_products_query', 'se_customize_product_shortcode', 10, 2 );

    It work’s great, but I have tabs on homepage for different product categories (watches, sunglasses) and now in this tabs it shows all products from all categories, so argument category in shortcode [product_category per_page=”8″ columns=”4″ category=”watches”]
    don’t work. Need help to fix it.
    So result must be working argument category for shortcode [product_category] + my hook, where I can disable some product’s showing by adding to it tag notshow

    https://www.ads-software.com/plugins/woocommerce/

  • The topic ‘Hide some product using tag’ is closed to new replies.