Mam klasę niestandardową Walker_Page
że mam rozszerzony tak:rozszerzony Walker_Page nie emituje zwyczaj start_lvl() lub() end_lvl
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", $depth);
$output .= "\n$indent</ul>\n";
}
}
Ale ja nie dostaję żadnego wyjścia z start_lvl
lub end_lvl
Funkcje. Czy jest tu coś, czego tu brakuje, czy też muszę wrócić? Otrzymuję dane wyjściowe <li>
z start_el()
.
Aktualizacja z wykorzystaniem
Oto jak używam Walker:
if ($post->post_parent) {
$ancestors=get_post_ancestors($post->ID);
$root = count($ancestors) - 1;
$top_parent = $ancestors[$root];
} else {
$top_parent = $post->ID;
}
$page_list_args = array(
'child_of' => $top_parent,
'depth' => 0,
'title_li' => false,
'walker' => new List_Nav
);
wp_list_pages($page_list_args);
Nie zwracasz zmiennej wyjściowej! prawda? – Thamilan
Powiedz nam, jak używasz tej klasy, abyśmy mogli odtworzyć twoją sprawę? – aeryaguzov
@Thamizhan Nic .. I nie otrzymuję niczego próbującego 'var_dump',' echo', 'return' lub nawet' die() '. –