Support » Fixing WordPress » menu ul class="

  • Resolved oritzio

    (@oritzio)


    Please help ,it’s driving me crazy…

    I’m using this code to load wordpress menu:
    <?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>

    How can i define the ul tags a class, for example:

    <ul class="mymenu">

Viewing 10 replies - 1 through 10 (of 10 total)
  • You should look at the codes page for wp_nav_menu(). You’ll find the answer there.

    <?php wp_nav_menu( array( 'theme_location' => 'header-menu', 'menu_class' => 'mymenu' ) ); ?>

    but this code doesn’t do it..
    what you sent me give me that:

    <div class="mymenu">
    <ul>
    <li></li>
    </ul>
    </div>

    and i want to give class to the ul tag

    <ul class="mymenu">
    <li></li>
    </ul>

    Please help =)!

    Are you using a custom nenu, or the default WordPress generated menu? From what I’ve seen this only works when using a custom menu that you’ve created (not sure if that’s a bug or a “feature”).

    what does it mean custom menu?

    I’ve started to design a theme from a blank template, and I’m trying to style my navigation…

    A custom menu is when you go into the ‘Appearance -> Menus’ area, create a menu there and assign it to your chosen menu area. It doesn’t sound like you’ve done that, so I would say that you haven’t got that set up. Like I said, from what I’ve seen, the menu_class doesn’t work on the standard WP menus for some reason. I don’t know why, but that’s jsut how it is.

    If you need to make changes to this I’d suggest wrapping the menu in a <div> tag and using that to define the styling. That way it will work no matter what the actual menu class is.

    yes, it’s custom menu!.. what next?

    Well, you can either go through the options in the codex page that I linked to above, or you can do what I said before and wrap the menu in a div tag so you can use that tags ID’s for styling, etc. That’s pretty much what you’re left with here.

    well.. that i knew already
    so there’s not solution for this..

    ok, Thanks anyway!

    what does it matter if it’s custom menu anyway?

    Found a solution by chrisburton

    If anyone would like to know how to define to ul tags a class:

    <?php wp_nav_menu( array('menu' => 'Main', 'container' => '', 'items_wrap' => '<ul id="mymenu">%3$s</ul>' )); ?>

    Working perfect!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘menu ul class="’ is closed to new replies.