WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With the WooCommerce plugin, I'm trying to get a different template/look to apply to the individual product page depending on what category the product is in. In other words, I want a product within the "A" category to have one look, and another product within the "Z" category to have another separate look. I realize there are similar questions asked, and I have used them to try and attempt this myself, but I'm having no luck getting them to work, so I would like to try something different: I need to place the following code:


Inside this IF statement: http://pastebin.com/WkhkEemH

Or some kind of similar conditional. So if the product has a category of "z", then echo out the html, css, and shortcode shown in the first pastebin link. If the product is not part of the "z" category then no extra html/css/shortcode is shown.

share|improve this question
up vote 1 down vote accepted

Instead of getting all terms, looping over them and then searching your array, you can use the has_termconditinal tag ex:

if( has_term( 'z', 'product_cat',$post->ID ) ) {
    <div id="post-timer">
        <p class="timebuy">Time Left To Buy:</p>
        <div id="timer-wrap">
            <?php echo do_shortcode( '[tminus cid ="12" omitweeks="true" days=" " hours=" " minutes=" " seconds=" "/]' ); ?>
        </div><!--end timer-wrap-->
    </div><!--end post-timer-->
share|improve this answer
Fantastic sir! Works like a charm. Thank you very much! – Anthony Myers Jan 4 '13 at 21:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.