Pavel Nasonov
Pavel Nasonov

Reputation: 61

Wordpress menus

i m having a problem with menus. I had a template that wasnt originaly for WP. so i integrated it.

when i started the site there was only one menu which works great. i added <?php wp_nav_menu('primary'); ?> and its all ok

Now i need to add another one (custom links in the header section) sooo i used this method

register_nav_menus( array( 
    'header' => 'Header menu', 
    'footer' => 'Footer menu' 
  ) );

and recieved new locations for menus. for the second menu i added

<?php wp_nav_menu( array( 'theme_location' => 'header', 'menu_class' => 'nav-menu', 'fallback_cb' => false ) ); ?>

now the problem: there is a primary menu (it has few items) and the custom menu ( its currently empty)

when i add new page to custom menu its being shown in both primary and custom menus.

if i delete all the items from custom menu, primary menu items are back in place...

what is the problem? Thank you.

Upvotes: 1

Views: 114

Answers (1)

1cgonza
1cgonza

Reputation: 1588

If I understand correctly, it looks like you are pointing to the wrong registered menu in the wp_nav_menu(). Specifically in the theme_location.

When you are building the "second menu" which is the "footer", theme_location should be footer since that is the name you gave it in the register_nav_menus().

<?php wp_nav_menu(
  array( 'theme_location' => 'footer', // Change 'header' to 'footer'
         'menu_class' => 'nav-menu', 
         'fallback_cb' => false )
  );
?>

Upvotes: 2

Related Questions