Support » Fixing WordPress » Highlight current taxonomy menu

  • Resolved Archie22is


    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:

    	# 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 ) {
    			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=http://localhost/Traderzone/alcohol class="alcohol" >Alcohol</a>
    		<li class="page_item-2">
    			<a href=http://localhost/Traderzone/snacks class="snacks" >Snacks</a>
    		<li class="page_item-3">
    			<a href=http://localhost/Traderzone/steak class="steak" >Steak</a>

    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)
  • Hi guys,

    Again I am amazed by the power of WordPress. This is how I managed to solve the problem…. with just one line of code (AMAZED).


    If WordPress was a woman, I would consider marrying it…

    And this is my css code:

    	background-color: #d86f08;

Viewing 1 replies (of 1 total)
  • The topic ‘Highlight current taxonomy menu’ is closed to new replies.