Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

http://pastebin.com/q18EJYZQ

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
add comment

1 Answer

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-->
    <?php
}
share|improve this answer
    
Fantastic sir! Works like a charm. Thank you very much! –  Anthony Myers Jan 4 '13 at 21:45
add comment

Your Answer

 
discard

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.