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
  • Just FYI, add_theme_support('menus'); is completely redundant here. – Jacob Peattie Commented Sep 10, 2019 at 0:26
Add a comment  | 

1 Answer 1

Reset to default 0

This 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