admin管理员组文章数量:1130349
I have a menu that looks like this:
Women and Men har the top level menu items while the lower nagivation menu items are the children.
The menu structure looks like this:
Women
New styles
Clothes
Jeans
Dresses
Shirts
Underwear
Men
New styles
Clothes
Jeans
T-shirts
Shirts
Underwear
If I click on "Women", children of the Women menu item will be shown in the lower navigation. If I click on "Men", children of the Men menu item will be shown in the lower navigation.
Displaying the top level menu items (Women and Men) is easy. I'm doing it like this:
<?php wp_nav_menu(
array(
'theme_location' => 'main-menu', // Menu ID registered in functions.php
'walker' => new Custom_Primary_Nav_Menu(),
'depth' => '1', // Show levels. (0 = all)
'container' => 'nav', // What container element to wrap the nav with
'fallback_cb' => false // If the menu doesn't exists, the navigation will fall back to 'wp_page_menu'
)
); ?>
However displaying the children are not so easy. The 'depth' parameter is not enough.
I need to display menu items from 2nd level to infinity thereby excluding the top level items.
How can I do this?
I wan't to use only 1 menu for everything if possible so that it's easy to show a mobile navigation with everything in it.
I have a menu that looks like this:
Women and Men har the top level menu items while the lower nagivation menu items are the children.
The menu structure looks like this:
Women
New styles
Clothes
Jeans
Dresses
Shirts
Underwear
Men
New styles
Clothes
Jeans
T-shirts
Shirts
Underwear
If I click on "Women", children of the Women menu item will be shown in the lower navigation. If I click on "Men", children of the Men menu item will be shown in the lower navigation.
Displaying the top level menu items (Women and Men) is easy. I'm doing it like this:
<?php wp_nav_menu(
array(
'theme_location' => 'main-menu', // Menu ID registered in functions.php
'walker' => new Custom_Primary_Nav_Menu(),
'depth' => '1', // Show levels. (0 = all)
'container' => 'nav', // What container element to wrap the nav with
'fallback_cb' => false // If the menu doesn't exists, the navigation will fall back to 'wp_page_menu'
)
); ?>
However displaying the children are not so easy. The 'depth' parameter is not enough.
I need to display menu items from 2nd level to infinity thereby excluding the top level items.
How can I do this?
I wan't to use only 1 menu for everything if possible so that it's easy to show a mobile navigation with everything in it.
本文标签: theme developmentShow all menu levels except top level How to exclude top level of a menu
版权声明:本文标题:theme development - Show all menu levels except top level. How to exclude top level of a menu? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749121162a2319030.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论