Category Navbar Highlighting
-
At the top of my page is a navbar that uses tabs to display my categories. What I would like to do is have it highlight the current viewed tab, which I’ve somewhat achieved with the below code.
<?php $catList = explode('<br />', wp_list_categories('echo=0&show_count=0&title_li=&style=none')); foreach ($catList as $cat) { $iPos = strpos($cat, '>'); if (is_category()) { $addclass = ' class="current_page"'; } else { $addclass = '';} // add the opening span tag behind the opening anchor tag $strLink = "<li" . $addclass . ">" . substr($cat, 0, $iPos) . '><span>' . substr($cat, $iPos + 1) . '</li>'; // add the closing span tag before the closing anchor tag echo str_replace('</a>', '</span></a>', $strLink); } ?>
The problem is that when I click on a category it shows all of the category tags highlights and not just the selected one. I also noticed while viewing the source that it added in an extra
- ><span>
at the end, but haven’t been able to figure out why.
Any help would be greatly appreciated.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Category Navbar Highlighting’ is closed to new replies.