可能的代码:
<?php
$children = wp_list_pages(\'title_li=&child_of=\'.$post->ID.\'&echo=0&depth=1\');
if ($children) { ?>
<ul id="three-menu">
<?php echo $children; ?>
</ul>
<?php } //ends (if($children)//
elseif($post->post_parent) { //if no children, try to get parent page and show siblings pages including the page itself
$siblings = wp_list_pages(\'title_li=&child_of=\'.$post->post_parent.\'&echo=0&depth=1\');
if ($siblings) { ?>
<ul id="three-menu">
<?php echo $siblings; ?>
</ul>
<?php } //ends if($siblings)// ?>
<?php } else { //optional: if no children and if no parent, then show all top level pages
$pagelist = wp_list_pages(\'title_li=&echo=0&depth=1\');
if ($pagelist) { ?>
<ul id="three-menu">
<?php echo $pagelist; ?>
</ul>
<?php } //ends if($pagelist)// ?>
<?php } ?>
包含大量冗余编码,以保持结构简单易懂。