WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
<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 ?

share|improve this question

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


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.