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.

I am using Event Manager and they have a custom post type of events, with a taxonomy of event-categories (separate from regular post categories). In that taxonomy I have created terms(?) or event categories, "Education" and "Research". I want a specific <div> to show up if a post is in the event-categories taxonomy with the term/category of "Education". The slug is "education" and the tag_ID is 8. Currently I'm trying to use this code snippet, but I'm not getting it. I know there's more to it, but I haven't been successful with other tutorials. Most are for category archives. I need it conditionally for single posts.

<?php
   if(in_category('education')) {
      echo '<div>test</div>';
   }
?>
share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

in_category() is conditional tag for taxonomy 'category'. With custom taxonomies you should use has_term() conditional, first parameter is term to check for and second is taxonomy.

if ( has_term( 'education', 'event-categories' ) ){
    echo '<div>Test</div>';
}
share|improve this answer
    
Worked perfectly. Thank you! –  chris_s Mar 30 '12 at 19:00
    
@chris_s you're very welcome. –  Mamaduka Mar 30 '12 at 21:24
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.