WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] menu ul class=" (11 posts)

  1. oritzio
    Member
    Posted 1 year ago #

    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">

  2. michael.mariart
    Member
    Posted 1 year ago #

    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' ) ); ?>

  3. oritzio
    Member
    Posted 1 year ago #

    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 =)!

  4. michael.mariart
    Member
    Posted 1 year ago #

    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").

  5. oritzio
    Member
    Posted 1 year ago #

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

  6. michael.mariart
    Member
    Posted 1 year ago #

    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.

  7. oritzio
    Member
    Posted 1 year ago #

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

  8. michael.mariart
    Member
    Posted 1 year ago #

    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.

  9. oritzio
    Member
    Posted 1 year ago #

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

    ok, Thanks anyway!

  10. oritzio
    Member
    Posted 1 year ago #

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

  11. oritzio
    Member
    Posted 1 year ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.