I’m a beginner with WorpPress and I want to create a menu.
I read the “Function Reference/wp nav menu” in the codex but I don’t understand why ul
is not created.
See my code:
<?php
if ( has_nav_menu( 'main-nav' ) ) {
wp_nav_menu(
array(
'theme_location' => 'main-nav',
'menu' => '',
'container' => 'nav',
'container_class' => 'navbar-collapse collapse',
'container_id' => '',
'menu_class' => 'nav navbar-nav navbar-right',
'menu_id' => 'menu-menu-principale',
'echo' => true,
'fallback_cb' => false,
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '<ul class="%2$s">%3$s</ul>',
'items_wrap' => '%3$s',
'depth' => 0,
'walker' => ''
)
);
} ?>
and see what it’s show, there is no ul
between nav
and li
:
<nav class="navbar-collapse collapse"><li id="menu-item-4" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-4"><a href="#">Accueil</a></li>
<li id="menu-item-5" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-5"><a href="#">Page d'exemple</a></li>
<li id="menu-item-30" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-30"><a href="#">Contact</a></li>
</nav>
Here my functions.php:
add_theme_support('nav-menus');
function register_my_menus() {
register_nav_menus(
array(
'main-nav' => __('Navigation principale'),
'extra-menu' => __('Menu Extra')
)
);
}
add_action( 'init', 'register_my_menus' );