0

Today I have faced an weird problem regarding WordPress menus. Here is the register function of my menus -

function register_adaptive_menus() {
register_nav_menus(array(
'top-menu' => __( 'Top Menu', 'adaptive-framework' ),
'main-menu' => __( 'Main Menu', 'adaptive-framework' )
));
}
add_action( 'init', 'register_adaptive_menus' );

And here's the two location where I've called those -

Location 1 :

<nav class="top-menu-navigation clearfix">
<?php wp_nav_menu(array(
'theme-location' => 'top-menu'
)); ?>
</nav>

Location 2 :

<nav class="main-navigation clearfix">
<?php wp_nav_menu(array(
'theme-location' => 'main-menu'
)); ?>
</nav>

So whenever I'm creating a menu for main menu it overrides the top menu that I've created in the backend of my WP installation and show same elements in both the location. Any idea why this is happening? Till I set Main Menu, both the location is receiving the same menu that I've set for the Top Menu.

2 Answers 2

1

There's a typo in your arguments. Instead of 'theme-location' it should be 'theme_location'. Here is the Codex as reference.

0

Firstly, you made a mistake in your code in the place of theme-location it should be theme_location.And Go to Appearance -> Menus and select different types of locations for different types of menus.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.