最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Problems Displaying Multiple WP Menus

programmeradmin0浏览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.

:)

发布评论

评论列表(0)

  1. 暂无评论