Try this instead: $terms = get_terms('MYTAX'); $currentterm = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); foreach ($terms as $term) { $class = $currentterm->slug == $term->slug ? 'live' : '' ; echo '<li class="'. $class .'"><a href="http://website.com/?MYTAX='. $term->slug .'">' . $term->name . '</a></li>'; } Basically you just need to reset your `$class` variable back to an empty string after your conditional has returned false, otherwise it will continue to remain true. Its seems odd, but once you know how to handle it, its all good.