Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
<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 ?

share|improve this question

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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