2013-07-24 25 views
1

我需要把主动类的<li>所以,当你在一个team_category它会显示<li class="active">添加一个wordpress的主动类

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

回答

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; ?> 
+0

什么是$ current_team !!! – deemi

+0

我发明了一些代表“如果你处于team_category”部分的问题。 – AmazingDreams

相关问题