WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] custom menu duplicating items from one menu to the other. (5 posts)

  1. kvnmcwebn
    Member
    Posted 1 year ago #

    I have two custom menus going in a footer.
    When I was using this <?php ( wp_nav_menu ('Footer-nav') ) ?> to call each menu the same menu items were getting rendered for each location.

    When I used this: <?php wp_nav_menu( array( 'container' =>'','fallback_cb' => '', 'depth' => 1, 'theme_location' => 'Footer-two' ) ); ?> for one menu it renders correctly in the correct location. But.. the other custom footer menu being called with <?php ( wp_nav_menu ('Footer-nav') ) ?> also renders the links from the "Footer-two".
    I have them both registered, both have menu items.
    Under each location the correct men is selected. What is the proper way to call two custom menus that are in two different divs?

    This is the function:

    add_action( 'init', 'my_custom_menus' );
    function my_custom_menus() {
    	register_nav_menus(
    		array(
    			'Footer-nav' => __( 'Footer-nav' ),
    			'Footer-two' => __( 'Footer-two' )
    	 		)
    	);
    }

    This is the call in the footer:

    <div id="footernavone">
    <?php ( wp_nav_menu ('Footer-nav') ) ?>
    </div>
    
    <div id="footernavtwo">
    This is footer two
    <?php wp_nav_menu( array( 'container' =>'','fallback_cb' => '', 'depth' => 1, 'theme_location' => 'Footer-two' ) ); ?>
    
    </div>
  2. kvnmcwebn
    Member
    Posted 1 year ago #

    oh and if I use:

    <?php wp_nav_menu( array( 'container' =>'','fallback_cb' => '', 'depth' => 1, 'theme_location' => 'Footer-two' ) ); ?>

    to call both items I just get an error. So there is something in the way that I'm calling them that I'm not getting right.

  3. Jay
    Member
    Posted 1 year ago #

    Just a suggestion. Try registering your menus like so.

    //Register Navs
    register_nav_menus( array(
    	'footer_nav' => 'Footer Nav',
    	'footer_two' => 'Footer Two'
    ) );

    Then call them like so

    //Call Navs
    <div id="footernavone">
    <?php wp_nav_menu(array('menu' => 'Footer Nav')); ?>
    </div>
    <div id="footernavtwo">
    <?php wp_nav_menu(array('menu' => 'Footer Two')); ?>
    </div>
  4. kvnmcwebn
    Member
    Posted 1 year ago #

    very nice thanks jay.

  5. Jay
    Member
    Posted 1 year ago #

    Reviewing the codex it is kind of confusing, Im not sure of the difference between this and this. Im not sure why they say to wrap register_nav_menus in a function like you had it when it is a function itself. Maybe someone smarter then me can explain, because I would like to know as well. Maybe Alchymyth can explain it, he is pretty good at that. Either way, Im glad you got it working.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.