最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

navigation - Wordpress nav_menu items from another menu appearing

programmeradmin3浏览0评论

In my website i'm using two separate nav_menus, one to the legal pages and other for the main navbar... For some reason some items of the main menu are appearing in the secondary menu, even though in the backoffice the menu is correct

Backoffice display of the menu

Website screenshot displaying the menus:

wp query of the main menu

$argsMenu = array('theme_location' => 'Main');
<?php wp_nav_menu($argsMenu); ?>

wp_query of the secondary menu

<?php wp_nav_menu($menuSecondary = array(
                                        'container'       => 'div',
                                        'container_class' => 'menu__secondary__content',
                                        'menu_class'      => 'menu__secondary',
                                        'echo'            => true,
                                        'items_wrap'      => '<div class="menu__secondary__wrap">%3$s</div>',
                                        'theme_location'  => 'Seconday',
                                    )); ?>

Thanks in advance , its a simple problem that is making me insane

In my website i'm using two separate nav_menus, one to the legal pages and other for the main navbar... For some reason some items of the main menu are appearing in the secondary menu, even though in the backoffice the menu is correct

Backoffice display of the menu

Website screenshot displaying the menus:

wp query of the main menu

$argsMenu = array('theme_location' => 'Main');
<?php wp_nav_menu($argsMenu); ?>

wp_query of the secondary menu

<?php wp_nav_menu($menuSecondary = array(
                                        'container'       => 'div',
                                        'container_class' => 'menu__secondary__content',
                                        'menu_class'      => 'menu__secondary',
                                        'echo'            => true,
                                        'items_wrap'      => '<div class="menu__secondary__wrap">%3$s</div>',
                                        'theme_location'  => 'Seconday',
                                    )); ?>

Thanks in advance , its a simple problem that is making me insane

Share Improve this question asked Jan 10, 2020 at 18:04 Pedro FerreiraPedro Ferreira 1791 silver badge10 bronze badges 3
  • 1 do you have a typo in 'theme_location' => 'Seconday'? 'Seconday' instead of 'Secondary'? – Captain S. Commented Jan 10, 2020 at 18:17
  • this is my code : register_nav_menus(array( 'Main' => 'Header Menu', 'Secondary' => 'Secondary Menu', )); – Pedro Ferreira Commented Jan 13, 2020 at 8:49
  • it was a typo , fixed it ! such a stupid mistake ! thanks – Pedro Ferreira Commented Jan 13, 2020 at 9:32
Add a comment  | 

1 Answer 1

Reset to default 0

I am sure you went down this path already, but be sure register menus and support for theme:

register_nav_menus(
    array(
        'Main' => 'Main Navigation',
        'Secondary' => 'Secondary Menu'
    )
);

And then follow your pattern of 'theme_location' => 'Secondary' to print your registered menu back.

发布评论

评论列表(0)

  1. 暂无评论