首页 文章

Wordpress:子菜单无法渲染

提问于
浏览
0

我是新手,wordpress,stackoverflow和php,我正在尝试在wordpress中构建原始主题 .

我已经在“标准菜单”的名称下设置了我的主菜单,我在管理菜单面板,functions.php和header.php中都指定了它,但我的子菜单没有生成 . 我检查了深度,它设置为三(3) . 我用谷歌搜索了几个小时,但我找到的所有解决方案都与css或html问题有关(某些东西是生成的,而且没有正确显示)与某些东西没有生成 . 我检查了我的菜单并且它的名称正确,它有三个级别的菜单(Parent,Child,Grandchild),但只生成了父级 .

我正在使用bootstrap,但我不相信这与我的CSS有任何关系,而是它的wordpress没有输出子元素(子菜单) .

这是关联数组,它是我的头文件的第1-10行:

<?php
// Create associative array 
$mainMenu = array( //format parameters for menu(s) in header/sidebars/things
    "theme_location" => "Standard Menu", //
    "container" => "", //
    "menu_class" => "dropdown-menu",
    "container_class" => "", // left empty, could be container_id;
    "container_id"=> "main_nav",
    "depth" => 3 ); //Depth is how many levels of menu - main, child, subchild
?>

这是 Headers 代码的头部分,第54-79行:

<header>
    <!--<h1><a href="<?php bloginfo('url');  ?>"><?php bloginfo("name");  ?></a></h1>-->
    <!--<h1><?php bloginfo("description"); //Descript access tagline ?></h1>-->
    <!-- navigation --> 
    <div class="navbar-wrapper">
        <!-- Wrap the .navbar in .container to center it within the absolutely positioned parent. -->
        <div class="container">

            <div class="navbar">
                <div class="navbar-inner">  
                    <div class="container">

                    <a class="homelink" href="<?php bloginfo('url');  ?>"><?php bloginfo("name");  ?></a>
                        <ul class="nav">                                
                            <?php if (function_exists('getNavMenu')): ?>
                                <?php echo getNavMenu('Standard Menu'); ?>
                            <?php endif; ?>
                        </ul>
                    </div>
                </div>
            </div>
        </div><!-- /.navbar-wrapper -->

    <div class="clear"><a name="top"></a></div>
</header>

这是函数文件:

<?php
/* Hi Portia - There is a kitty hidden somewhere in this theme - enjoy! */

//register_nav_menu("main_menu", "Main Navigation Menu");   
/* How to remove 'tight' coupling in menu dashboard */

// ..._menu for one or menus for more then one
// first name -> used to call menu in script/code
// second name -> used by dashboard

$menuList = array (
    //Changed 'Menu' to 'Standard Menu' to match admin menu panel/header

    "main_menu" => "Standard Menu", // name based on usability
    "util_menu" => "Util Menu: Upper Right", //Named where it appears
    "footer_menu" => "Footer Menu: Bottom"
);

register_nav_menus($menuList);

/* =====----- Adds login/logout link to nav -----+++++ */
add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
function add_login_logout_link($items, $args) {
        ob_start();
        wp_loginout('index.php');
        $loginoutlink = ob_get_contents();
        ob_end_clean();
        $items .= '<li class="login" '. $loginoutlink .'</li>';
    return $items;
}

 /* =====----- LOAD CSS -----+++++ */
//function artisan_load_styles() {
//if (!is_admin()) {
//wp_enqueue_style('main', get_template_directory_uri() . '/style.css');
//wp_enqueue_style('bootstrap', get_template_directory_uri() . '/_css/bootstrap.css');
//wp_enqueue_style('responsive', get_template_directory_uri() . '/_css/bootstrap-responsive');
//wp_enqueue_style('ieSucks', get_template_directory_uri() . '/_css/ieresp.css');
//wp_enqueue_style('base', get_template_directory_uri() . '/_css/base.css');
//}
//}
//add_action('get_header', 'artisan_load_styles');

?>

网址:Wordpress site

1 回答

  • 0

    getNavMenu()函数是什么?在Wordpress中,生成菜单的函数是wp_nav_menu() . 有了这个功能,一切都应该是开箱即用的 .

相关问题