admin管理员组文章数量:1393056
I need to show menu with all subcategories for specific category (and sub category).
When code looks like this:
<?php if (is_category('news')) : ?>
<?php wp_nav_menu( array( 'theme_location' => 'news-menu' ) ); ?>
<?php endif; ?>
<?php if (is_category('articles')) : ?>
<?php wp_nav_menu( array( 'theme_location' => 'articles-menu' ) ); ?>
<?php endif; ?>
Menu is displayed correctly on main category page - in sidebar is shown full list of subcategories. When i am going to subcategory, for example news/sales - menu in sidebar is not appearing. To fix that i changed code like this:
<?php if (is_category('news') || in_category('news')) : ?>
<?php wp_nav_menu( array( 'theme_location' => 'news-menu' ) ); ?>
<?php endif; ?>
<?php if (is_category('articles') || in_category('articles')) : ?>
<?php wp_nav_menu( array( 'theme_location' => 'articles-menu' ) ); ?>
<?php endif; ?>
After that when i am in page of subcategory (let's say news/sales) menu is shown correctly, but in main category news i see both menus for news AND articles.
Any ideas how to make it work? That both main categories and their subpages will show only their own menus, not both menus which re avaliable?
本文标签: categoriesDisplay menu in category and sub category
版权声明:本文标题:categories - Display menu in category and sub category 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744772944a2624451.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论