wp_nav_menu how to wrap whole sub-menu inside div

1.6k views Asked by At

I'm trying to add div to wrap all submenus inside. Wordpress by default creates menu structure:

<ul id="menu-main" class="menu">
    <li>Parent
        <ul class="sub-menu">
            <li>Sub
                <ul class="sub-menu">
                    <li>Sub 1A</li>
                    <li>Sub 1B</li>
                </ul>
            </li>
            <li>Sub 2
                <ul class="sub-menu">
                    <li>Sub 2A</li>
                    <li>Sub 2B</li>
                </ul>
            </li>
        </ul>
    </li>
</ul>

I would like to add div to wrap all submenu into one div (for mega menu purpose) so it would look like:

<ul id="menu-main" class="menu">
    <li>Parent
        <div class="additional-div">
        <ul class="sub-menu">
            <li>Sub
                <ul class="sub-menu">
                    <li>Sub 1A</li>
                    <li>Sub 1B</li>
                </ul>
            </li>
            <li>Sub 2
                <ul class="sub-menu">
                    <li>Sub 2A</li>
                    <li>Sub 2B</li>
                </ul>
            </li>
        </ul>
    </div>
    </li>
</ul>

wordpress menu

0

There are 0 answers