[resolved] Multiple Custom Menus (4 posts)

  1. JeremyEnglert
    Posted 3 years ago #

    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:

    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?

  2. vtxyzzy
    Posted 3 years ago #

    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'));?>
  3. JeremyEnglert
    Posted 2 years ago #


    That was exactly the problem. Thanks for your help!

  4. vtxyzzy
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.