php - Wordpress menu: Remove list-items and apply ".current-menu-item" to anchor tag -


title says all. in short, how make wp_nav_menu(); output this:

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

i read http://css-tricks.com/snippets/wordpress/remove-li-elements-from-output-of-wp_nav_menu/ removes unordered list , list-items.

but removing <li>s removes useful .current-menu-item class when you're on particular page. how class show on anchor tag instead?

you can edit output via first parameter of function wp_nav_menu($args);.

$args = array(     'theme_location'  => '',     'menu'            => '',     'container'       => 'div',     'container_class' => '',     'container_id'    => '',     'menu_class'      => 'menu',     'menu_id'         => '',     'echo'            => true,     'fallback_cb'     => 'wp_page_menu',     'before'          => '',     'after'           => '',     'link_before'     => '',     'link_after'      => '',     'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',     'depth'           => 0,     'walker'          => '' );  wp_nav_menu($args); 

see http://codex.wordpress.org/function_reference/wp_nav_menu full documentation.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -