0

当我尝试在 Wordpress 中显示我的任一二级菜单时,它将再次显示主菜单(“主菜单”)而不是'footer-menu'or 'info-menu'。我使用以下代码来显示我的菜单:

                wp_nav_menu( array(
                    'theme-location' => 'info-menu',
                    'depth'      => 1,
                    'container'  => false,
                    'menu_class' => 'nav-info',
                    'fallback_cb' => 'wp_page_menu')
                );

我在以下位置注册了我的菜单function.php

function register_my_menu() {

    register_nav_menus(
        array(
            'main-menu' => __( 'Main Menu', 'ibasketball' ),
            'footer-menu' => __( 'Footer Menu', 'ibasketball' ),
            'info-menu' => __( 'Info Menu', 'ibasketball' )
        )
    );
}
add_action( 'init', 'register_my_menu' );

任何帮助深表感谢。

4

2 回答 2

1

您的代码中有错字theme-location应该是theme_location Try wp_nav_menu(array('theme_location' => 'info-menu')); it will work

于 2014-07-08T09:53:59.653 回答
0

从 codex 中,只有一个参数可用register_nav_menus

用法

 <?php register_nav_menus( $locations ); ?> 

参数

$locations

(array) (required) An associative array of menu location slugs (key) and descriptions (according value).
Default: None

请参阅 codex 以获取更多详细信息codex

于 2013-09-05T12:54:42.987 回答