1

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
  }
?>
4

1 回答 1

0

像这样的东西应该工作。

<?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; ?>
于 2013-07-24T16:00:02.520 回答