I am trying to target a specific category from a custom taxonomy. This is for WooCommerce.

So, the custom taxonomy is called "product_cat" and the category itself is called "adult-dvds".

This is what I tried; however, it didn't work (nothing shows up between the comment tags):

    <!-- Custom Fields -->
    <?php if (is_tax('product_cat','adult-dvds')) { ?> 
        <p>blah blah blah</p>
    <?php } ?>
    <!-- End Custom Fields -->

Is there something I missed?


I ended up using this bit of code and it worked:

<?php if (has_term('adult-dvds','product_cat')) { ?> 
    <p>blah blah blah</p>
<?php } ?>
| improve this answer | |
  • as of 2015. This worked for me! @desi – breezy Aug 5 '15 at 19:43

Are your custom taxonomy's slug is product-cat? The is_tax() function need parameter of the taxonomy slug, not the id. So this should work:

if (is_tax('product-cat','adult-dvds')) {
    // do something
| improve this answer | |
  • Unfortunately, this didn't work. – Desi Sep 1 '12 at 16:51
  • What I mean by that is that, still, nothing is showing up between the comment tags. – Desi Sep 1 '12 at 17:46
  • are you opening with kind like /product-cat/adult-dvds? if yes, this conditional sholud work. – rizqyhi Sep 2 '12 at 3:26
  • Hm, it's still not working. Do you think I should be using something other than is_tax? – Desi Sep 2 '12 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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