2013-05-13 126 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