0

I register 2 menus in my functions.php file:

register_nav_menus(array(
    'main_menu' => 'Main Menu',
    'bottom_menu' => 'Bottom Menu'
));

I populate a menu in the admin and assign the theme location:

Assigning menu location

I call the menu in my theme:

<?php
    wp_nav_menu('menu', 'main_menu');
?>

After doing all this, bottom_menu is the menu showing up in my theme instead.

Can anyone tell me what I'm doing wrong? Either I'm missing something really silly here or Wordpress is giving me the finger.

2
  • 1
    wp_nav_menu() takes array of arguments, see usage examples in documentation.
    – Rarst
    Nov 22, 2013 at 15:28
  • Resolved! It was the theme_location argument.
    – jagershark
    Nov 22, 2013 at 15:42

1 Answer 1

2

By specifying a theme_location argument in my array, the issue was fixed:

wp_nav_menu(array(
    'theme_location' => 'main_menu'
));

Edit

For a distributed Theme, do not pass the 'menu' parameter to the wp_nav_menu() call. It will look for a specific slug of a user-created menu, and will override 'theme_location'. Only ever pass 'theme_location'.

0

Your Answer

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

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