09 Oct, 2010
wp_nav_menu and 'container' => false appears to not work
Posted by: Jennifer In: WordPress|WordPress: Lessons Learned
A quick post to deal with a problem I've come across again and again. I think I see the issue now, and wanted to make a note of what I *think* I'm seeing. I've also seen some complain about this same problem too.
When you use wp_nav_menu() to create your nav bar, it will automatically add a container div that wraps around your navigation (which is presented in an unordered list). However, maybe you don't want that div there. According to the codex, you should only have to create your nav with 'container' => false to get that container to go away, but for some reason, on what was seeming like random occasions, it would have no affect.
Well, I realized that the reason for this is because I had not yet set up my menu specifically. As soon as I went into the admin, created a menu, and assigned it to the same location wp_nav_menu() was calling, voila! The container went away.
I understand that if there is no menu set up yet, that wp_nav_menu() resorts to calling wp_list_pages(), but it should still pay attention to the arguments passed to the original function. However, it definitely seems like it is having issues. Not sure if that's a bug or not, but now I know (or at least I THINK I know) what's happening and how to fix it.
Reference: WordPress 3.0.1