Я использую следующий код для отображения моего меню 3 уровня:
if(!$post->post_parent){
// will display the subpages of this top level page
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
}else{
// diplays only the subpages of parent level
//$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
if($post->ancestors) {
// now you can get the the top ID of this page
// wp is putting the ids DESC, thats why the top level ID is the last one
$ancestors = end($post->ancestors);
$children = wp_list_pages("title_li=&child_of=".$ancestors."&echo=0");
// you will always get the whole subpages list
}
}
if ($children) { ?>
<ul id="submenu">
<?php echo $children; ?>
</ul>
<?php } ?>
Он отображает страницы в боковой панели, второй уровень, а затем и третий уровень. Я бы тоже хотел включить очень верхний уровень, чтобы моя структура выглядела следующим образом:
*A
-a
--a
-b
--b
-c
--c
Где, как указано выше, код не перечисляет главную страницу, т. Е. * A, я надеюсь, что это имеет смысл, и кто-то сможет помочь
Спасибо