• I’m trying to implement wp_nav_menu in my wordpress theme. I have a problem though, I don’t want it wrapped in a div, I want it wrapped in just a ul. How do I do this?

Viewing 15 replies - 1 through 15 (of 22 total)
  • https://codex.www.ads-software.com/Function_Reference/wp_nav_menu

    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…..

    Thread Starter mloberg

    (@mloberg)

    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.

    Why is the wrapper div a problem?

    Thread Starter mloberg

    (@mloberg)

    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.

    Thread Starter mloberg

    (@mloberg)

    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.

    What was the output?

    Thread Starter mloberg

    (@mloberg)

    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.

    Thanks!

    Aimee

    (@greatdanemaniac)

    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!

    //Anna-Maria

    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 https://codex.www.ads-software.com/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?

    Thanks ??

    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>

    Hey
    I am having a similar problem to all you guys but I need to get rid of the menu_id or override it because it is preventing the list from appearing for me.
    How do I do this, its driving me crazy!

    Thanks

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘wp_nav_menu getting rid of div’ is closed to new replies.