tetetetet


'menu-1',
'depth' => 3,
'container' => 'div',
'container_class' => 'test_menu',

'walker' => new cs_walker_nav_menu
) );
?>

class cs_walker_nav_menu extends Walker_Nav_Menu {
function start_lvl( &$output, $depth ) {
$output .= "

";
}
function start_el( &$output, $item, $depth, $args ) {
if (in_array('menu-item-has-children', $item->classes)) {
// 親の場合
$output .= "\n" . $indent . '

  • '.$this->create_a_tag($item, $depth, $args);
    }
    else {
    // 子の場合
    $output .= '

  • ';
    $output .= $this->create_a_tag($item, $depth, $args);
    }
    }
    function end_el( &$output, $item, $depth, $args ) {
    if (in_array('menu-item-has-children', $item->classes)) {
    // 親の場合
    $output .= '
  • ';
    }
    else {
    // 子の場合
    $output .= '

    ';
    }
    }
    private function create_a_tag($item, $depth, $args) {
    // link attributes
    $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 ) .'"' : '';
    //$attributes .= ' class="menu-link ' . ( $depth > 0 ? 'sub-menu-link' : 'main-menu-link' ) . '"';

    $item_output = sprintf( '%1$s%3$s%4$s%5$s%6$s',
    $args->before,
    $attributes,
    $args->link_before,
    apply_filters( 'the_title', $item->title, $item->ID ),
    $args->link_after,
    $args->after
    );
    return apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
    }
    }

    アクリロニトリルブタジエンスチレン樹脂 single.php