WordPress.org

Ready to get started?Download WordPress

Forums

Add menu classes for each level (4 posts)

  1. Timmito
    Member
    Posted 2 years ago #

    Hey everybody,

    I've got a quite complex navigation menu that needs some ul classes to display properly. The navigation consists of nested lists. I know how to target each level within css (ul li ul li) dependant on their position. What I really need is to add a class to the uls on the same level. I want to use the default wordpress nav, so no custom menu required.
    Example:
    1st level ul (class="level1")
    2nd level ul (class="level2")
    ...

    You might ask why! The thing is that this will be a mega menu combined with a flyout. And there will be images on different navigation levels (e.g. first level, second level) based on the hierarchy.

    Thanks in advance!

    Tim

  2. vtxyzzy
    Member
    Posted 2 years ago #

    Here is a short article with a link to a tutorial on using a Walker class to modify a WP menu:

    http://wordpress.mcdspot.com/2011/07/30/tutorial-on-walker-class-for-wp_nav_menu/

  3. Timmito
    Member
    Posted 2 years ago #

    Hey, thanks for your reply...

    Unfortunately I was not able to figure this out with a custom Walker class. But I found a solution to my question with class names:

    http://stackoverflow.com/questions/5034826/wp-nav-menu-change-sub-menu-class-name

    I am currently using it in the project. But there's one requirement that brings me back to your tutorial link. I need to add the post thumbnail and excerpt of a page to my wp_nav_menu. But only, if there's no subpage for that item.

    Maybe any idea?

    Regards,

    Tim

  4. vtxyzzy
    Member
    Posted 2 years ago #

    No, sorry!

Topic Closed

This topic has been closed to new replies.

About this Topic