Remove wrapper <div> from wp_nav_menu output

I am trying to remove a shell from the wp_nav_menu () function.

I passed container => false to the arguments array and added a hook to my functions.php file, but it still shows the shell.

function my_wp_nav_menu_args( $args ) { $args['menu'] = false; $args['menu_class'] = false; $args['container'] = false; $args['container_class'] = false; $args['show_home'] = true; return $args; } 

Any ideas why?

+4
source share
1 answer

Code Reading: Feature Reference / wp nav menu

You may need to set the location of the theme in the functions.php file, and then assign it your own menu?

This is what the code says:

To remove the container for navigation, specify the theme location specified in functions.php and used among the arguments in the wp_nav_menu function (for example, 'theme_location' => 'primary-menu') must have a menu assigned to it in the administration! The argument to othervise 'container' => 'false' is ignored.

If you need to register a place, you can use the following:

 // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => __( 'Primary Navigation', 'Your_Theme' ), ) ); 

Then pass it to the wp_nav_menu() function

 wp_nav_menu( array( 'theme_location' => 'primary', 'container' => false ) ); 

Hope this helps!

+3
source

All Articles