Support » Themes and Templates » The problem with in wp_nav_menu

  • Let me start off with what I am definitely not looking for because they’re not helpful:

    • “What’s wrong with using WordPress’s default HTML output?” (because if WordPress’s default HTML output were acceptable I wouldn’t be asking the question)
    • A link to the function reference (I’ve read it, repeated, and other than the fact that I can see the WordPress codex is in desperate need of a halfway decent technical writer, I think I grok everything there is there)
    • A link to another thread (the other threads are jumbled, meandering, and full of the other two answers that I don’t want).


    wp_nav_menu() provides an option for suppressing the wrapping <div> tag that goes around the menu.
    Either by 'container' => false or else 'container' => ''

    In addition, WordPress identifies custom navigation menus as A Thing That Themes Ought To Support. I agree with this point. People want to put in their own menus, not be told what their menus have to be. Ok, I get it, good.

    the ‘container’ option only works if you
    a) have a named theme_location in the options
    and b) the menu identified with that option has been set in the admin panel

    Basically, I don’t get WHY ON GOD’S GREEN EQUESTRIA that condition would be stipulated.

    This means that out of the box functionality is going to be different from functionality where the user has made their own menu, or else there’s absolutely no reason at all to suppress the <div> wrapper.

    What if the user LIKES the out of the box menu in the theme?

    If you think I have any of my information here wrong, feel free to tell me, but I’ve done just about every combination of code I can think of. And no matter what, if there’s no menu defined in the admin panel, there’s no way to get rid of that <div>. setting container => ”, setting container => false. Identifying the theme location. Not identifying the theme location.

    So, two things i’m looking for.
    1) A fix for the dilemma that DOESN’T require me to tell anyone installing the theme that they have to tweak their settings
    2) An explanation for why ignoring the request to suppress the <div> wrapper would be a good idea?

  • The topic ‘The problem with in wp_nav_menu’ is closed to new replies.