I'm working on a fallback menu for a WordPress theme I'm working on. The main menu's menu_class renders a ul which is what I want.

However, if I use the menu fallback, the menu_class renders a div instead. Is there a way to make Wordpress render a ul for the fallback menu instead of a div?

Here's my code:

 function clarity_main_nav_fallback() {


    'show_home' => true,
    'container' => false,                           // remove nav container
    'container_class' => 'menu clearfix',           // class of container (should you choose to use it)
    'menu_class' => 'nav navbar-nav'              // adding custom nav class



2 Answers 2


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.

  • You are right @Chip Bennet! I was totally confused.
    – Johann
    Oct 3, 2013 at 16:44

You have a problem with menu location

Go to

Dashboard >> Appearance >> Menus >> " Open Your Menu Name "

    => Find at " Display Location " in  " Menu Setting"

    => check " primary menu " [ if you have uncheck]

enter image description here

  • Sorry, but that really does not answer the question. Maybe you want to read it again and edit your answer?
    – kaiser
    Apr 10, 2017 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.