wp_nav_menu getting rid of div
shows the available args
I haven’t worked much with this yet, but it looks like you would play around with the format parameter? Or the container actually? Somethin to go on anyway…..
I was messing with it and I couldn’t get anything to change. It was frustrating.
I would love to assist with this issue, however, I need to know what you are trying to accomplish in order to help.
I built a theme. The top nav bar is wrapped in a div of links. I was using wp_list_pages, with the addition of a “hard coded” home page.
I now want to use wp_nav_menu. When I replaced wp_list_pages with wp_nav_menu, it was already inside a ul, because I had that hard coded home button.
So what I’m trying to do is get rid of the div and ul so I can keep the hard coded home. I suppose I could also get rid of the hard coded home and just put that in the custom nav, right? But then I would need to changed the name of the wp_nav_menu div to links. I tried this, but I could not get it to work.
Is this a vertical or horizontal menu? I’m just wondering if you could sidestep the problem using CSS.
Horizontal. I could sidestep the problem if I could rename the div to links. But I couldn’t get it, maybe I was typing something wrong.
wp_nav_menu( array(‘container_id’ => ‘links’) ); I tried this and it didn’t work.
It doesn’t change at all. It’s wrapped in a div called menu and then a ul.
I’ve been playing with it as well, similar problem. I’m working with the most current beta.
I enabled the menu in functions:
add_theme_support( 'nav-menus' );
In my theme page where I wanted to menu I put:
wp_nav_menu(array('menu' => 'Main Dropdown Nav', 'container' => 'nav', 'container_id' => 'mainnav' ));
It did change the container to nav but there was not id for that container.
This should probably be moved to the beta forum.
mloberg: Can you please tell me how your CSS code for the menu looks like? I’d really like to build a theme myself compatible with WP 3.0, but I don’t know how I should make the menu in CSS. I would be really happy if you could share that information with me.
You can contact me either here, or by my website. Thanks!
I am experiencing the same thing, very few of the options args for wp_nav_menu seem to work. I’ve tried it in my own theme as well as in the new Twenty Ten them as well.
Args either don’t work or work differently than the reference page states at http://codex.wordpress.org/Function_Reference/wp_nav_menu
menu_class: CSS class to use for the ul element which forms the menu
However, setting this sets a CSS class on the containing div, despite the fact that container_class is supposed to be the argument that affects this.
Other than that I’m finding other args just don’t work, echo for instance has no effect. Is this something everyone is encountering and therefore a bug or is there likely a problem with my installation?
Ok, a combination of user error here and perhaps the Codex reference being a little unclear 😉
I finally got the code to work the way I wanted, I used this code to bring in my menu:
<?php $args = array( 'menu' => 'mainnav', 'menu_class' => 'container_12', 'menu_id' => 'navigation', 'container' => false, 'theme_location' => 'primary-menu'); wp_nav_menu($args); ?>
Basically this gets rid of the container div, puts a class and an ID on the UL of the menu and also specifies the menu location for use in the theme.
Hi all, I am having the same problem as rickrurran. All I want is the menu to be within <div id=”Navigation”> but the arguments passed to wp_nav_menu() have no affect on the output. Setting menu_class is the only argument which works to style the output 🙁 Any ideas? Thanks!
<?php wp_nav_menu( array( 'menu' => 'Masthead Navigation', 'container_id' => 'Navigation' ) ); ?> Generates the following: <div class="menu"> <ul> <li class="page_item page-item-4 current_page_item"> <a href="" title="Home">Home</a> </ul> </div>
- The topic ‘wp_nav_menu getting rid of div’ is closed to new replies.