categories - Display menu in category and sub category

I need to show menu with all subcategories for specific category (and sub category).When code looks like this:<?php i

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744772944a4592871.html

相关推荐

  • categories - Display menu in category and sub category

    I need to show menu with all subcategories for specific category (and sub category).When code looks like this:<?php i

    16小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信