0
votes

I am trying to convert HTML to Wordpress and I am having troubles with menus.

The menu is a 3 level drop-down menu, I am outputting it with wp_nav_menu and this is how it formats.

    <ul id="nav" class="sf-menu">
         <li>Home</li>
         <li>Blog</li>
             <ul class="sub-menu">
                 <li>Level 2</li>
                     <ul class="sub-menu">
                         <li>Level 3</li>
                     </ul>
             </ul>
         <li>Portfolio</li>
         <li>Contacts</li>
    </ul>

Basically I want to remove the "sub-menu" class from the /s in the 2nd level and 3rd level.

This is how I want it to be:

     <ul id="nav" class="sf-menu">
         <li>Home</li>
         <li>Blog</li>
             <ul>
                 <li>Level 2</li>
                     <ul>
                         <li>Level 3</li>
                     </ul>
             </ul>
         <li>Portfolio</li>
         <li>Contacts</li>
    </ul>

Is this possible to do with a custom walker class?

2

2 Answers

1
votes

There is a wordpress 'setting' fkr that:

As you can see:Function Reference/wp nav menu

you can remove the ul by writing this when you call the wp_nav_menu:

<?php wp_nav_menu( array( 'items_wrap' => '%3$s' ) ); ?>

this should work. you also have some other Parameters for the nav menu: it's id, container_class and more.

-1
votes

you can use below code :

$(function() {
    $('.sf-menu ul').removeClass('sub-menu');
});