First, I think you’re confusing the wp_nav_menu()
args. The 'menu_class'
parameter defines the class added to the menu element, which by default is <ul>
, as per the 'items_wrap'
parameter. The default 'menu_class'
is 'menu'
, which results in <ul class="menu">
.
The real issue is actually the fallback_cb
– the callback used when no menu is defined – which defaults to wp_page_menu()
.
Now, both wp_nav_menu()
and wp_page_menu()
output an unordered list (<ul>
) wrapped by a container (<div>
) by default. In your call to wp_nav_menu()
, you have: 'container' => false
, which overrides the menu list being wrapped by a container <div>
. But that parameter does not get passed to the default wp_page_menu()
callback output.
The easiest solution would be to define your own callback:
wp_nav_menu( array(
// Add your normal args here
'fallback_cb' => 'wpse116656_nav_menu_cb'
) );
Then declare your callback function:
function wpse116656_nav_menu_cb() {
wp_page_menu( array(
// Args here
) );
}
Now, here’s the caveat:
-
wp_nav_menu()
applies the'menu_class'
parameter to the unordered list(
<div><ul class="$menu_class"></ul></div>
) -
wp_page_menu()
applies the'menu_class'
parameter to the wrapper container outside the menu list(
<div class="$menu_class"><ul></ul></div>
)
So, you’ll need to account for that with your CSS.