add a wordpress active class

i need to put an active class on the <li> so the that when you are in a team_category it would display <li class="active">

<?php 
$sport = get_terms( 'team_category' ); 

  if($sport){
     ?><ul><?php
     foreach($sport as $s){ ?>
       <li><a href="<?php echo get_term_link( $s->slug, 'team_category' ) ?>"><?php echo $s->name; ?></a></li>
     <?php }
    ?></ul><?php
  }
?>

Related posts

Leave a Reply

1 comment

  1. Something like this should work.

    <?php $sport = get_terms( 'team_category' ); ?>
    
    <?php if($sport): ?>
    <ul>
       <?php foreach($sport as $s): ?>
           <li class="<?php if($current_team == $s): ?>active<?php endif; ?>">
               <a href="<?php echo get_term_link( $s->slug, 'team_category' ) ?>"><?php echo $s->name; ?></a>
           </li>
       <?php endforeach; ?>
    </ul>
    <?php endif; ?>