【问题标题】:How to create multilevel navigation with AMP using walker-menu?如何使用 walker-menu 使用 AMP 创建多级导航?
【发布时间】:2019-03-07 08:03:44
【问题描述】:

我正在使用带有 AMP 的 wordpress。 我找到了这段代码,但它只显示了 2 个级别:https://github.com/better-studio/better-amp/blob/master/includes/classes/class-better-amp-menu-walker.php

这就是我调用菜单的方式

wp_nav_menu( array(
            'menu'              => 'primary',
            'depth'             => 2,
            'container'         => 'nav',
            'container_class'   => 'amp-menu swipe-menu hidden-desktop',
            'container_id'      => 'amp-menu',
            'menu_class'        => 'nav navbar-nav',
            'walker'            => new Walker_AMP_Menu())
        );

有没有办法让它多层次? 示例:

item 1
item 2
  -item 2.1
  -item 2.1
     -item 2.1.1
     -item 2.1.2
item 3
item 4
item 5

【问题讨论】:

标签: wordpress amp-html wp-nav-walker


【解决方案1】:

显然问题出在这部分,它只允许2个级别

if ( $this->has_children && $depth == 0) {
        add_theme_support( 'better-amp-has-nav-child', TRUE );

        $this->start_accordion( $output, $depth );

        $output .= '<h6 class=' .$depth.'><span ' . $class_names . '>';
        $output .= $this->get_anchor_tag( $item, $depth, $args, $id );
        $output .= '</span></h6>';

        $this->start_accordion_child_wrapper( $output, $depth );

    } else {

        $output .= '<span id='.$depth.' ' . $class_names . '>';
        $output .= $this->get_anchor_tag( $item, $depth, $args, $id );
        $output .= '</span>';

    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多