• Resolved Chris

    (@lamordnt)


    Hi,
    I am trying to modify a template file in single-product.php to show some text if the product is in a certain category. I am trying to use the is_category_product but cannot seem to get it to work.

    Here is the code I am trying to use:

    <?php if ( is_product_category( '40' )):?>This video will be mailed to you in DVD format.<?php else : ?> This Video will be Delivered Via Instant Download. High Speed Internet Connection Reccommended. <?php endif;?>

    Any suggestions on how to get this to work?
    Thanks so much in advance!

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

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

    (@lamordnt)

    Figured it out….

    <?php
    global $post;
    $terms = wp_get_post_terms( $post->ID, 'product_cat' );
    foreach ( $terms as $term ) $categories[] = $term->slug;
    
    if ( in_array( 'digital-downloads', $categories ) ) {
      echo 'This Video will be Delivered Via Instant Download.  High Speed Internet Connection Reccommended.';
    } else {
      echo 'This video will be mailed to you in DVD format.';
    } ?>

    Found the answer here:

Viewing 1 replies (of 1 total)
  • The topic ‘Show if is in a certain category’ is closed to new replies.