I'm developing a new theme and am encountering a weird behaviour.
I have registered a footer menu:
register_nav_menus([
'primary_navigation' => "Main nav",
'footer_navigation' => "Footer nav"
]);
In the template, primary_navigation
menu shows correctly the custom menu created in the Administration zone.
But footer_navigation
does not. In fact, it returns false:
if (has_nav_menu('footer_navigation')) {
?>
<ul class="c-footnav__list flex-container" role="navigation">
<?php
if(!wp_nav_menu( array( 'theme_location' => 'footer_navigation', 'depth'=>10, 'echo'=>true ))){
echo "could not print menu";
}; ?>
</ul>
<?php
}
It prints the <UL>
element and the "could not print menu" message.
The documentation regarding wp_nav_menu()
says:
(object|false|void) Menu output if $echo is false, false if there are no items or no menu was found.
So I must assume that it does not find the menu. But why then the call to has_nav_menu('footer_navigation')
returns true ? What am I missing?