Highlight current taxonomy menu
-
Hi guys,
I have deleted the default WordPress menu (no need for it on the site) and implemented a Category/Taxonomy menu. I am making use of the default WordPress categories to generate the menu.
I have the following code:
<?php # Navigation Taxonomy Menu ---> so dynamic it's unbelievable! $mylinks = get_terms('category', array( 'parent' => 0, # display parent category links only 'orderby' => 'name', 'hide_empty' => 0 ) ); $count = count($mylinks); if ( $count > 0 ) { # From the above, we create a menu foreach ( $mylinks as $mylink ) { $i++; echo '<li class="page_item-' . $i . '">'; // add incrementing value to id page # get current webdirectory and link to taxonomy menus echo '<a href=' . network_site_url() . '/' . $mylink->slug . ' class="'. $mylink->slug .'" >'; echo $mylink->name; echo "</a>"; echo "</li>"; } } ?>
The menus are generated fine and work and group the categories as expected.
My only problem is that I cannot highlight the current selected category using CSS. This is how the html code looks:
<nav class="clearfix"> <ul class="menu clearfix"> <li class="page_item-1"> <a href=https://localhost/Traderzone/alcohol class="alcohol" >Alcohol</a> </li> <li class="page_item-2"> <a href=https://localhost/Traderzone/snacks class="snacks" >Snacks</a> </li> <li class="page_item-3"> <a href=https://localhost/Traderzone/steak class="steak" >Steak</a> </li> </ul> </nav>
How will I get to intergrate a “active” id to add some css? jQuery or can it be done within php?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Highlight current taxonomy menu’ is closed to new replies.