2013-05-13 118 views
0

我是一個新手,wordpress,stackoverflow和PHP,我正在嘗試在wordpress中構建一個原創主題。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 
?> 

這裏是標頭碼的頭部,線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'); 

>

URL:Wordpress site

+1

調查functions.php並搜索getNavMenu函數。這是你的菜單得到渲染的地方。在此處粘貼該功能的代碼。 – user850010 2013-05-13 14:45:14

回答

0

getNavMenu()函數是什麼?在Wordpress中,生成菜單的函數是wp_nav_menu()。有了這個功能,所有的東西都應該可以運行。

+0

我已經將我的函數文件添加到了原始文章中。謝謝。 – Chezshire 2013-05-14 15:07:46