Add Custom attributes to the menu container with wp_nav_menu

Updated on     Kisan Patel

Problem:

How to add custom attributes to the menu container with wp_nav_menu in wordpress?

I already have a custom walker in place that handles some of the <li> and <a> tags, but I can’t seem to access the outer <ul> that wraps the menu items.

Solution:

You need to pass the items_wrap parameter as shown in below example:

wp_nav_menu('items_wrap' => '<ul id="%1$s" class="menu" for="bar">%3$s</ul>'

Wordpress

Leave a Reply