Support » Fixing WordPress » wp_nav_menu custom walker class to add li-class for children

  • Hi everybody,

    I extended the wp-nav-menu walker class and need to get a custom class into the children list.
    I assume it must be coded into the start_el function starting at line 67:
    http://phpxref.ftwr.co.uk/wordpress/nav.html?wp-includes/nav-menu-template.php.source.html
    I copied it to my functions.php

    I managed to get the “topnav” added to the parent list but failed with the nested ul subnav list-class.
    it should look like this:

    <ul id="navigation">
    <li><a href="#">Home</a></li>
    <li class="topnav"><a href="#">Subs</a>
       <ul>
       <li class="subnav"><a href="#">Sub-Link 1</a></li>
       <li class="subnav"><a href="#">Sub-Link 2</a></li>
       </ul>
    </li>
    </ul>

    thanks for every help.

  • The topic ‘wp_nav_menu custom walker class to add li-class for children’ is closed to new replies.