0
<ul id="menu">
        <li><a href="#">About Assetline</a>
        <li><a href="#">Products & Services</a>
            <div id="mega">
                <ul>
                <li><a href="#">Commercial Credit</a></li>
                </ul>    

                <ul>
                <li><a href="#">Portfolio Management</a></li>   
                </ul>
            </div><!--mega-->
        </li>
        <li><a href="#">News & Events</a>
        </ul>

This is the menu structure what I want to integrate into wordpress . But there's an issue to add a div id ( ) inside of a menu . Any idea to achieve this ?

2

I think use Custom Walker.

First register a custom navigation menu for this list in your theme’s functions.php

class WP_Walker extends Walker_Nav_Menu
{
    function start_lvl( &$output, $depth = 0, $args = array() ) {
        $indent = str_repeat("\t", $depth);
        $output .= "\n$indent<div id='mega'><ul class='sub-menu'>\n";
    }
    function end_lvl( &$output, $depth = 0, $args = array() ) {
        $indent = str_repeat("\t", $depth);
        $output .= "$indent</ul></div>\n";
    }
}

After register custom navigation. Usage below code in your theme:

wp_nav_menu(array ('theme_location' => 'your-theme-location', 'walker' => new WP_Walker));

Use a custom walker, extend the methods start_lvl() and end_lvl.

custom walker

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.