admin管理员组文章数量:1122832
I'm learning WordPress and I'm can't understand what I'm doing wrong with a theme I'm creating. Here is how I create my menus in the functions.php
file
function my_custom_theme_setup() {
add_theme_support('menus');
register_nav_menu('header', 'Menu that goes in the header of the website');
register_nav_menu('footer', 'Menu that goes in the footer of the website');
}
add_action('init', 'my_custom_theme_setup');
And here is how I insert it the header.php
: <?php wp_nav_menu(array('menu' => 'header','menu_class' => 'header__nav'));?>
Here is how I configured the menu in the admin interface:
Yes, the content of both menus is different. The footer menu is OK, but the header one is not. What am I doing wrong?
I'm learning WordPress and I'm can't understand what I'm doing wrong with a theme I'm creating. Here is how I create my menus in the functions.php
file
function my_custom_theme_setup() {
add_theme_support('menus');
register_nav_menu('header', 'Menu that goes in the header of the website');
register_nav_menu('footer', 'Menu that goes in the footer of the website');
}
add_action('init', 'my_custom_theme_setup');
And here is how I insert it the header.php
: <?php wp_nav_menu(array('menu' => 'header','menu_class' => 'header__nav'));?>
Here is how I configured the menu in the admin interface:
Yes, the content of both menus is different. The footer menu is OK, but the header one is not. What am I doing wrong?
Share Improve this question asked Sep 9, 2019 at 16:11 André LuizAndré Luiz 1191 silver badge3 bronze badges 1 |1 Answer
Reset to default 0This is what solved the issue:
<?php wp_nav_menu(array('theme_location' => 'header','menu_class' => 'header__nav'));?>
本文标签: wpnavmenu seems to be printing the wrong menu
版权声明:本文标题:wp_nav_menu seems to be printing the wrong menu 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736292387a1928922.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
add_theme_support('menus');
is completely redundant here. – Jacob Peattie Commented Sep 10, 2019 at 0:26