【发布时间】:2011-03-11 12:55:46
【问题描述】:
我正在使用以下代码来显示我的 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,我希望这是有道理的,有人能够提供帮助
谢谢,
【问题讨论】:
-
你能澄清一下吗?如果您在页面--a 上,您想在侧边栏中显示什么?如果您在页面 -b 上,您希望在侧边栏中显示什么?