Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
添加<;李>;wordpress中子菜单项之间的标记_Wordpress - Fatal编程技术网

添加<;李>;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

我想在WordPress的导航子菜单中添加一个
  • 。在我想要添加的每个子菜单项之间。目前,我正在使用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.'
  • '; $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 .= $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 .'>';