小编Vin*_*ack的帖子

扩展的Walker_Page不输出自定义的start_lvl()或end_lvl()

我有一个Walker_Page我这样扩展的自定义类:

class List_Nav extends Walker_Page {
  function start_lvl( &$output, $depth = 0, $args = array() ) {
    $indent = str_repeat("\t", $depth);
    $output .= "\n$indent<ul class='ListNav'>\n";
  }

  function start_el(&$output, $page, $depth = 0, $args = array(), $current_page = 0) {
    $output .= '<li class="ListNav-item">';
    $output .= '<a class="ListNav-link" href="' . get_permalink($page->ID) . '">' . apply_filters( 'the_title', $page->post_title, $page->ID ) . '</a>';
    $output .= '</li>';
  }

  function end_lvl( &$output, $depth = 0, $args = array() ) {
    $indent = str_repeat("\t", …
Run Code Online (Sandbox Code Playgroud)

php wordpress

5
推荐指数
1
解决办法
548
查看次数

标签 统计

php ×1

wordpress ×1