Support » Fixing WordPress » Multiple Custom Menus

  • Resolved JeremyEnglert

    (@jeremyenglert)


    I recently added custom menu support to my WordPress theme. I was able to get my primary navigation working correctly, but my footer navigation doesn’t seem to want to change.

    Here is the code I used in my functions.php file:

    //Navigation
    add_action('init','register_custom_menu');
    function register_custom_menu(){
    register_nav_menus( array(
    	'custom_menu' => 'Custom Menu',
    	'footer_menu' => 'Footer Menu'
    ) );
    }

    Here is the code I used in my footer (not working):
    <?php wp_nav_menu (array('menu'=>'footer_menu'));?>

    Here is the code from my primary navigation, which is working:
    <?php wp_nav_menu (array('menu'=>'custom_menu'));?>

    The footer position shows up in the Menu back-end, but when I edit it or re-arrange pages, no changes are made.

    Amy ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I believe the problem is due to confusion between ‘menu’ and ‘theme_location’. register_nav_menu assigns a ‘menu’ to a ‘theme_location’ like this:

    'theme_location' => 'menu'

    The code in the primary navigation is working because wp_nav_menu will fall back to the first non-empty menu if the ‘theme_location’ argument is not provided and the ‘menu’ can not be found.

    Try using this:

    <?php wp_nav_menu (array('theme_location'=>'footer_menu'));?>

    @vtxyzzy

    That was exactly the problem. Thanks for your help!

    If your problem has been solved, please use the dropdown on the right to mark this topic ‘Resolved’ so that anyone else with this question can see that there is a solution.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple Custom Menus’ is closed to new replies.