wordpress - Add id to menu items in wp_nav_menu -


i'm using wp_nav_menu in wordpress create navigation

the output similar this(i have removed href links)

    <nav id="pagenav">         <ul id="menu-headernav" class="menu">           <li><a href="">home</a></li>         <li><a href="">about</a></li>         <li><a href="">services</a></li>         <li><a href="">work</a></li>         <li><a href="">contact</a></li>       </ul>              </nav> 

i need style each link separately.

how can add id each (li) or (a) in menu can style it.

the li tags have id generated wordpress. @ least in install.

for a tag, can add id attribute writing in function in theme's function.php file , hook nav_menu_link_attributes filter.

check out wordpress core at: http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/nav-menu-template.php#l89

function my_id_attribute ($atts, $item, $args) {   //develop anchor tag id nomenclature i'll call $id   $atts['id'] = $id;   return $atts;   } add_filter('nav_menu_link_attributes', 'my_id_attribute', 3, 10); 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -