wp_nav_menu() doesn’t apply correctly classes and IDs to menu and container

I wrote this simple code to prove what I’m saying:

wp_nav_menu( [
‘menu’ => ‘Primary Navigation’,
‘menu_class’ => ‘this-is-the-menu-class’,
‘menu_id’ => ‘this-is-the-menu-id’,
‘container’ => ‘div’,
‘container_class’ => ‘this-is-the-container-class’,
‘container_id’ => ‘this-is-the-container-ID’,
] );

This is the output:

<div id=”this-is-the-menu-id” class=”this-is-the-menu-class”>
<ul>
<li class=”page_item page-item-2″>
<a href=”http://localhost/test_site/index.php/pagina-di-esempio/”>Example Page.</a>
</li>
</ul>
</div>

As you can see the ul element doesn’t receive any class nor ID.

They, instead, are applied to the container and the container classes and ID seem to be simply missed (or getting the default values).

In the documentation is told that

‘menu_class’ (string) CSS class to use for the ul element which forms the menu. Default ‘menu’.
‘menu_id’ (string) The ID that is applied to the ul element which forms the menu. Default is the menu slug, incremented.
‘container’ (string) Whether to wrap the ul, and what to wrap it with. Default ‘div’.
‘container_class’ (string) Class that is applied to the container. Default ‘menu-{menu slug}-container’.
‘container_id’ (string) The ID that is applied to the container.

But as you can see the result is not the one expected.

In this discussion the user set wrong the container param, and so the replies point out this error, but the error still exists and I’m doing all following the rules (at least I think!).

Am I doing something wrong or effectively the function is bugged?

NOTEs:

I’m using Genesis Framework (just in case it may be useful to understand the context)
Wordpress version is 4.9.4

Read more here:: wp_nav_menu() doesn’t apply correctly classes and IDs to menu and container

Leave a Reply

Your email address will not be published. Required fields are marked *