我是 wordpress、stackoverflow 和 php 的新手,我正在尝试在 wordpress 中构建一个原始主题。
我已经在名称“标准菜单”下设置了我的主菜单,我在管理菜单面板、functions.php 和 header.php 中都指定了它,但是没有生成我的子菜单。我检查了深度,它设置为三 (3)。我已经用谷歌搜索了几个小时,但我发现的所有解决方案都与 css 或 html 问题有关(生成了一些东西并且没有正确显示)与没有生成一些东西。我检查了我的菜单,它的命名正确,它有三个级别的菜单(父、子、孙),但只生成了父级。
我正在使用引导程序,但我不相信这与我的 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');
?>
网址:WordPress 网站