WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Issue with custom menus (3 posts)

  1. awalls
    Member
    Posted 1 year ago #

    Hi,

    I am having a strange problem with a theme I am developing in that as part of the theme I have defined two menu areas a main nav and a footer nav. I have defined these in my function.php file as follows:

    if (function_exists('register_nav_menus')) {
      register_nav_menus(
        array(
          'main_nav'    => "Main Nav Menu",
          'footer_nav'  => "Footer Menu"
        )
      );
    }

    Now within my theme I can see that it now supports two navigation areas:

    http://awesomescreenshot.com/0d5499k9b

    And within my header.php and footer.php I have defined the following:

    <div id="nav-bar">
      <ul class="cf">
        <?php wp_nav_menu(
          array(
            'menu'	=> 'main_nav',
          ));
        ?>
      </ul>
    </div>

    and

    <ul class="menu cf floatLeft">
      <?php wp_nav_menu(
        array(
          'menu'	=> 'footer_nav',
        ));
      ?>
    </ul>

    However both menus areas always show the main menu even if from within the menus area I have defined one to us main and the other to use footer. Even more confusiing if I leave both of these blank I'd expect to see no menu displayed in these areas but it always displays the main menu.

    Would appreciate some advice as to where I might be going wrong.

  2. vtxyzzy
    Member
    Posted 1 year ago #

    The parameters to wp_nav_menu are confusing. I think that 'main_nav' and 'footer_nav' are actually theme_location's. Give this a try:

    <ul class="menu cf floatLeft">
      <?php wp_nav_menu(
        array(
          'theme_location'	=> 'footer_nav',
        ));
      ?>
    </ul>
  3. awalls
    Member
    Posted 1 year ago #

    Thanks, that worked. The parameters are a bit confusing. Am a WP newbie and just getting used to its "idiosyncrasies" :)

Topic Closed

This topic has been closed to new replies.

About this Topic