我用下面的代碼,以顯示我的3級菜單:WordPress站點導航
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上,你想在邊欄中顯示什麼? – Groovetrain 2011-03-11 18:37:22