WordPress.org

Ready to get started?Download WordPress

Forums

How to highlight current menu items (4 posts)

  1. marion1203
    Member
    Posted 2 years ago #

    Hi!

    I just started WordPress and I'd like to enhance current menu items. Ive tokena look on every posts about about that but im still stuck. So here is my php code forthe menu ( I have submenu):

    <div class="menu">
    
    			<?php wp_nav_menu(array(
    			'theme_location' => 'nav',
    			'menu' => 'header',
    			'depth'=> 1,
    			)
    			); ?>
    </div>		
    
    <div class="submenu">
    <ul><li> <a>
    <?php
      if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    
      echo $children;
     ?>
    </a> </li> </ul> </div>

    and here is the class I want for current menu items :

    .menu ul li .selected {
    	color: #336699;
    	border-left: 1px dotted #999999;
    } 
    
    .submenu ul li .selected {
    	color: #336699;
    	border-left: 1px dotted #999999;
    }

    Could someone help me with that?

    Thank you very much

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    the menu codes output their own 'current' css classes;
    for instance:

    http://codex.wordpress.org/Function_Reference/wp_nav_menu#Menu_Item_CSS_Classes

  3. marion1203
    Member
    Posted 2 years ago #

    Thank for you quick answer, actually I already tried to replace the class selected by current-menu-item, but it didn't work either. that is why I tought there is a problem n my php code. Well actually I dont really know.

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    Try using Firefox with the Firebug add-on for this kind of CSS work.
    http://getfirebug.com/

Topic Closed

This topic has been closed to new replies.

About this Topic