添加<;李>;wordpress中子菜单项之间的标记
我想在WordPress的导航子菜单中添加一个添加<;李>;wordpress中子菜单项之间的标记,wordpress,Wordpress,我想在WordPress的导航子菜单中添加一个。在我想要添加的每个子菜单项之间。目前,我正在使用Walker_Nav_菜单来显示主导航菜单的说明 class Menu_With_Description extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_re
。在我想要添加的每个子菜单项之间。目前,我正在使用Walker_Nav_菜单来显示主导航菜单的说明
class Menu_With_Description extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
$class_names = ' class="' . esc_attr( $class_names ) . '"';
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= '<br /><span class="sub-text">' . $item->description . '</span>';
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"dropdown-menu\">\n";
}
}
带有描述的类菜单扩展了Walker导航菜单{
函数开始(&$output、$item、$depth、$args){
全局$wp_查询;
$indent=($depth)?str_repeat(“\t”,$depth):”;
$class_name=$value='';
$classes=空($item->classes)?array():(array)$item->classes;
$class_name=join(“”,应用_过滤器('nav_menu_css_class',数组_过滤器($classes),$item));
$class_names='class=“”.esc_attr($class_names)。”;
$output.=$indent.'请帮助。您应该更新以下行:
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
$output.=$indent.'';
致:
if($depth==0){
如果($item->menu_order>1)$output.=$indent.;
$output.=$indent.'';
}否则{
$output.=$indent.' ';
}
An要更改li class=“dropdown”中A的类,请编辑该行:
$item_output .= '<a'. $attributes .'>';
$item\u输出。='';
致:
if($depth==0)
$item_输出='';
其他的
$item_输出='';
你有更多的控制权,但这一切都取决于你的需要,当然也取决于你的技巧:)
if( $depth==0 ){
if($item->menu_order > 1) $output .= $indent . '<li class="divider"></li>';
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
}else{
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
}
$item_output .= '<a'. $attributes .'>';
if( $depth==0 )
$item_output .= '<a'. $attributes .' class="dropdown-toggle" data-toggle="dropdown">';
else
$item_output .= '<a'. $attributes .'>';