admin管理员组文章数量:1406926
I want to ask if this <?php wp_nav_menu( array('theme_location' => 'primary') ); ?>
get all the sub-menu automatically? I saw this one of my downloaded theme and it displays all the submenu only using this and css code. I am curious why it display the submenu even though it doesn't uses walker class for example like this
wp_nav_menu( array(
'theme_location' => 'primary',
'depth' => 2, // 1 = no dropdowns, 2 = with dropdowns.
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'navbar-nav mr-auto',
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
'walker' => new WP_Bootstrap_Navwalker(),
) );
with another walker file like this . I am new to wordpress and I hope someone would enlighten me. Thanks
I want to ask if this <?php wp_nav_menu( array('theme_location' => 'primary') ); ?>
get all the sub-menu automatically? I saw this one of my downloaded theme and it displays all the submenu only using this and css code. I am curious why it display the submenu even though it doesn't uses walker class for example like this
wp_nav_menu( array(
'theme_location' => 'primary',
'depth' => 2, // 1 = no dropdowns, 2 = with dropdowns.
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'navbar-nav mr-auto',
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
'walker' => new WP_Bootstrap_Navwalker(),
) );
with another walker file like this https://github/wp-bootstrap/wp-bootstrap-navwalker
. I am new to wordpress and I hope someone would enlighten me. Thanks
1 Answer
Reset to default 1Yes, wp_nav_menu
displays all levels of menu by default.
You don't have to write your custom walker class to display submenu items - WordPress already has one which is used by default.
WP_Bootstrap_Navwalker
is used only because given theme uses Bootstrap and nav menu should generate custom HTML code, which is compatible with Bootstrap.
The only thing you have to remember is that there is depth
argument which decides how many levels of menu should be printed.
本文标签: walkerDisplaying Nav Menu
版权声明:本文标题:walker - Displaying Nav Menu 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744984407a2636006.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论