I’m trying to remove the wrapper from the wp_nav_menu() function.
I’ve passed container => false to the arguements array and added a hook in my functions.php, but it still shows the wrapper.
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?
Reading the codex: Function Reference/wp nav menu
You may need to set the Theme Location in your functions.php file and then assign your menu to it?
This is what is says in the codex:
If you need to register a location you can use the following:
Then pass it in the
wp_nav_menu()
functionHope this helps!
I have passed null to container and menu is not wrapped in div tag.
I think the boolean data type it’s not available for this Parameters, please read this Function Reference/wp nav menu
So the best way to remove this div wrapper replace it with ul, like this example
An existing menu have to be associated to your location (‘footer-1’ in my example), otherwise, there is always a div wrapper.
In my case
"container" => false
doesn’t work, It only works when you write"items_wrap" => "%3$s"
but it removes all wraps including<ul>
if you want to remove<div>
and have your menu wrapped in<ul>
I recommend to do this way