WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Conditional Tags on Single Product Pages (4 posts)

  1. mharmontx
    Member
    Posted 1 year 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 1 year 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 11 months ago #

    Could you use is_product()? WooCommerce Conditional Tags

  4. BowsDesign
    Member
    Posted 5 months ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic