【发布时间】:2017-09-28 15:35:05
【问题描述】:
我正在尝试更改我网站上导航的标记,而且我对开发 wordpress 还是很陌生,但是我在让它显示我的 Walker 课程时遇到了问题。我正在尝试重新配置 Wordpress 附带的 2017 主题。但是我不断收到这个错误,上面写着“致命错误:在第 56 行的 /wp-content/themes/Vibe/header.php 中找不到类 'Walker_Nav_Primary'” 这是该类的样子:
<?php
class Walker_Nav_Primary extends Walker_Nav_menu {
function start_lvl( &$output, $depth = 0, $args = array() ){ //ul
$indent = str_repeat("\t",$depth);
$submenu = ($depth > 0) ? ' sub-menu' : '';
$output .= "\n$indent<ul class=\"dropdown-menu$submenu depth_$depth\">\n";
}
/*
function start_el( ){ //li a span
}
function end_el(){ // closing li a span
}
function end_lvl(){ // closing ul
}
*/
}
以及我调用它的头文件部分:
<?php wp_nav_menu( array(
'theme_location' => 'top',
'menu_id' => 'primary-menu',
'menu_class' => 'head-menu',
'walker' => new Walker_Nav_Primary(),
) ); ?>
编辑:
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'top' => __( 'Top Menu', 'twentyseventeen' ),
'social' => __( 'Social Links Menu', 'twentyseventeen' ),
) );
【问题讨论】:
标签: php wordpress wordpress-theming