• Hi,

    I am trying to add role=”navigation” to the menu ul.

    Using wp_nav_menu you can only change the ID or the CLASS but you cannot add role=””. I did some research and found out about the new walker function. I managed to add role=”” to the sub menu’s but not to the menu ul.

    simplified example:

    the basic output normally would be

    <ul id="menu-main">
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Contact</a></li>
        <li><a href="#">Blog</a></li>
    </ul>

    I want it to be

    <ul id="menu-main" role="navigation">
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Contact</a></li>
        <li><a href="#">Blog</a></li>
    </ul>

    Can you guys help me with this?! thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You should be able to include the following parameter in the array argument passed to wp_nav_menu():

    'items_wrap' => '<ul id="%1$s" class="%2$s" role="navigation" >%3$s</ul>'

    Thread Starter CAstijnen

    (@castijnen)

    That worked flawless, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_nav_menu: adding role="" to menu ul’ is closed to new replies.