• Resolved cintiastela

    (@cintiastela)


    I am trying to use the WooCommerce Conditional Tags to only include a template into specific product pages. https://docs.woocommerce.com/document/conditional-tags/

    However my statements aren’t working, and they show on all pages. I’d like to NOT display my template in a specific category and its product pages:

    // Show in Shop Page OR NOT in Products IDs 15852,15859,15863,15866 OR NOT Category Archive Gift Cards

    <?php if ( is_shop() || !is_product(array( 15852,15859,15863,15866 )) || !is_product_category( ‘gift-cards’ )) { get_template_part(‘my-template’); } ?>

    I’ve also tried the opposite:

    <?php if ( is_product(array(‘gift-card-25′,’gift-card-50′,’gift-card-75′,’gift-card-100’)) ) { get_template_part(‘my-template’); } ?>

    Can you please advise how to get it to work?

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter cintiastela

    (@cintiastela)

    The solution to my problem was to use:

    has_term( 'the-cat-I-want-to-display', 'product_cat' ) || is_product_category( 'the-cat-I-want-to-display' )

Viewing 1 replies (of 1 total)
  • The topic ‘WooCommerce IF statements not working’ is closed to new replies.