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

                <li><a href="#">Portfolio Management</a></li>   
        <li><a href="#">News & Events</a>

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 ?


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.