Problems Displaying Multiple WP Menus

admin2025-04-19  0

Not sure where my error is (I did piece most of this together from snippets on different websites,) but when I test my theme, only "Left Menu" displays. There are definitely two menus, however where "Menu Right" should be is a duplicate of "Menu Left."

Here's my header

<nav id="navigation" role="navigation">
   <?php wp_nav_menu( array('menu' => 'Left Menu' )); ?>
   <?php wp_nav_menu( array('menu' => 'Right Menu' )); ?>
</nav><!-- /Navigation -->

And here's my functions.php

function register_mp_menus() {
    register_nav_menus(
        array( 
            'left-menu' => __( 'Left Menu' ), 
            'right-menu' => __( 'Right Menu' )
        )
    );
}

add_action( 'init', 'register_mp_menus' );

Any ideas or help would be greatly appreciated!

Not sure where my error is (I did piece most of this together from snippets on different websites,) but when I test my theme, only "Left Menu" displays. There are definitely two menus, however where "Menu Right" should be is a duplicate of "Menu Left."

Here's my header

<nav id="navigation" role="navigation">
   <?php wp_nav_menu( array('menu' => 'Left Menu' )); ?>
   <?php wp_nav_menu( array('menu' => 'Right Menu' )); ?>
</nav><!-- /Navigation -->

And here's my functions.php

function register_mp_menus() {
    register_nav_menus(
        array( 
            'left-menu' => __( 'Left Menu' ), 
            'right-menu' => __( 'Right Menu' )
        )
    );
}

add_action( 'init', 'register_mp_menus' );

Any ideas or help would be greatly appreciated!

Share Improve this question edited Oct 16, 2019 at 22:43 CommunityBot 1 asked Jan 10, 2012 at 6:54 SamSam 111 silver badge2 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2

You need to define the theme location when displaying with wp_nav_menu, i.e.:

<?php
wp_nav_menu( array(
   'theme_location' => 'left-menu',
   'menu' => 'Left Menu'
    )
); ?>

The correct code is:

<nav id="navigation" role="navigation">
   <?php wp_nav_menu( array('theme_location' => 'left-menu' )); ?>
   <?php wp_nav_menu( array('theme_location' => 'right-menu' )); ?>
</nav><!-- /Navigation -->

Then you need to activate the menus in your admin interface: Appearances->Menus. If you want them to be duplicates of each other you just assign the same menu in your admin interface.

:)

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745074801a283503.html

最新回复(0)