WordPress.org

Forums

WooCommerce
Conditional Tags on Single Product Pages (4 posts)

  1. mharmontx
    Member
    Posted 2 years ago #

    This code from Woocommerce's website lets you target categories on your website to display messages. The only problem with this is that it does not work on Single Product pages.

    I'd like my single product pages to be able to display notes depending on their parent category.

    Any ideas?

    <?php
    if ( is_product_category() ) {
    if ( is_product_category( 'batteries' ) ) {
    echo 'Testing';
    } elseif ( is_product_category( 'games' ) ) {
    echo 'Testing';
    } else {
    echo 'Testing';
    }
    }
    ?>

    http://wordpress.org/plugins/woocommerce/

  2. mharmontx
    Member
    Posted 2 years ago #

    I'm trying to do something this >

    <?php if ( is_product_category('batteries') && is_single){ echo "This is a single post"; } ?>

    but it isn't working correctly.

  3. serons
    Member
    Posted 1 year ago #

    Could you use is_product()? WooCommerce Conditional Tags

  4. BowsDesign
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic