Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am changing wp_nav_menu() to make it a listless navigation menu (i.e., no unordered list or list item tags) Normally the menu <li> has the .current-menu-item class attached to it when active. But is there a way to give it to the anchor instead?

<a class="current-menu-item"></a>

Edit: This is currently what I'm doing to remove the tags... if there's a custom walker solution that would be ideal. I'd prefer not having to resort to using any javascript if possible.

$menuParameters = array(
  'container'       => false,
  'echo'            => false,
  'items_wrap'      => '%3$s',
  'depth'           => 0,
);

echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );
share|improve this question
    
Please elaborate on how exactly are you applying your tweaks. –  Rarst Jan 31 at 16:40
1  
I think you'd need to look at a custom Walker for this. Check out the Nav Menu docs for starters, and you'll find the Walker_Nav_Menu class (whcih you extend to make your custom walker) in /wp-includes/nav-menu-template.php. If that is what you want, update the question and I'll be happy to help. –  David Gard Jan 31 at 16:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.