0

How to remove ul-class in wp_nav_menu?

'items_wrap' => '%3$s',
'container' => false  

Adding above does not work.

2
  • Did you try menu_class parameter? Oct 31, 2014 at 11:56
  • Please specify what "does not work" mean. This is not a valid description. Please file an edit and explain what is wrong with your code, what exactly is not happening Oct 31, 2014 at 13:54

2 Answers 2

4

To remove ul class from wp_nav_menu, you will have to define menu_class to false. Default wp_nav_menu ul menu class is menu.

<?php wp_nav_menu( array( 'container' => false, 'items_wrap' => '<ul>%3$s</ul>', 'theme_location' => 'mainmenu' ) ); ?>

I added mainmenu as theme_location. You should change it to your theme location.

Read full list of args on wp_nav_menu codex page.

EDIT:

To remove id and classes from ul menu you can define your menu like this.

'container' => false,
'items_wrap' => '<ul>%3$s</ul>'
6
  • <?php wp_nav_menu( array( 'theme_location' => 'footer','container' => false, 'menu_class' => false,) ); ?> not work
    – user62857
    Oct 31, 2014 at 11:50
  • Please check edit. I have modified your code that will remove ids and classes from UL.
    – Robert hue
    Oct 31, 2014 at 11:52
  • <?php wp_nav_menu( array( 'theme_location' => 'footer','container' => false, 'items_wrap' => '<ul>%3$s</ul>') ); ?> It's not work too
    – user62857
    Oct 31, 2014 at 11:58
  • Please edit your question and explain what exactly is your HTML output right now and how do you want it. This code removes UL classes, I have tested it just now.
    – Robert hue
    Oct 31, 2014 at 12:01
  • Please check this screenshot ssmaker.ru/8b77bc30.png I need to do to look like the left column right. Title - this is the parent page, below are subsidiaries. And now the left speaker seems to ul - class
    – user62857
    Oct 31, 2014 at 12:06
-1

If you want to remove ul and div from the function wp_nav_menu(), you can use this code:

if ( function_exists( 'wp_nav_menu' ) ) {
    wp_nav_menu( array( 
        'menu'       => 'main_nav', // main_nav means menu id
        'container'  => '',
        'items_wrap' => '%3$s' 
    ) );
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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