WordPress.org

Support

Support » Plugins and Hacks » Custom meny walker

Custom meny walker

  • Hello there wordpress masters!

    I’m trying to generate a custom menu and have been trying in quite many ways now and can’t get a nice solution.
    I’ve read this article, wich is close to what i want to achieve; http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output

    But, it’s not really the way i want it…
    All the sub-menus get the class “sub-menu”. I want the first level of children to have another class, like “big-sub-menu”. Something like this…

    <ul class="MainMenu">
        <li class="MainMenuButton">
            Main Button 1
            <!-- If this menu item has children -->
            <ul class="big-sub-menu">
                <li>
                    Sub button 1.1
                    <!-- If this menu item has children -->
                    <ul class="sub-menu">
                        <li>Sub-Sub button 1.1.1</li>
                        <li>Sub-Sub button 1.1.2</li>
                    </ul>
                </li>
                <li>
                    Sub button 1.2
                    <!-- If this menu item has children -->
                    <ul class="sub-menu">
                        <li>Sub-Sub button 1.2.1</li>
                    </ul>
                </li>
                <li>
                    Sub button 1.3
                    <!-- No children, no sub menu -->
                </li>
            </ul>
        </li>
        <li class="MainMenuButton">
            Main Button 2
            <!-- If this menu item has children -->
            <ul class="big-sub-menu">
                <li>
                    Sub button 2.1
                    <!-- If this menu item has children -->
                    <ul class="sub-menu">
                        <li>Sub-Sub button 2.1.1</li>
                    </ul>
                </li>
                <li>
                    Sub button 2.2
                    <!-- No children, no sub menu -->
                </li>
            </ul>
        </li>
    </ul>

    The theme will actually just have a maximum for 3 levels of menus, but i don’t wanna loop and iterate this manually for three levels. Feels ugly. Better so learn right from the beginning.
    Any ideas?

  • The topic ‘Custom meny walker’ is closed to new replies.