Home > front end >  Exclude products with product shortocde Woocommerce
Exclude products with product shortocde Woocommerce

Time:07-19

I am trying to exclude products with shortcode but its not working

here is what i am using shortocode

[products limit="14" orderby="id" columns="4" order="DESC" visibility="visible" category="tcs" cat_operator="NOT IN"]

enter image description here

I used php filter also

function phl_customize_product_shortcode( $args, $atts ) {
    
    if ( is_front_page() ) {
        $args['tax_query'] = array(
            array(
                'taxonomy' => 'product_cat',
                'field'    => 'name',
                'terms'    => array( 'tcs' ),
                'operator' => 'NOT IN'
            )
       );

    }
    return $args;
}
add_filter( 'woocommerce_shortcode_products_query', 'phl_customize_product_shortcode', 10, 2 );

But still not working

here is site you can see

https://www.pottershouselimited.co.uk

CodePudding user response:

can you try this:

function phl_customize_product_shortcode( $args, $atts ) {
    
    if ( is_front_page() ) {
        $args['tax_query'] = array(
            array(
                'taxonomy' => 'product_cat',
                'field'    => 'slug',
                'terms'    => array( 'tcs' ),
                'operator' => 'NOT IN'
            )
       );

    }
    return $args;
}
add_filter( 'woocommerce_shortcode_products_query', 'phl_customize_product_shortcode', 10, 2 );

and tell me how it goes? also where on the website can i see the tcs items on homepage?

  • Related