<?php
if ($post->post_parent)    {

$ancestors=get_post_ancestors($post->ID);

$root=count($ancestors)-1;

$parent = $ancestors[$root];

} else {

$parent = $post->ID;

}
$children = wp_list_pages(“title_li=<h3>&child_of=”. $parent .”&echo=0″);
?>
<div id=”sidebar”>
<div id=”wrapbox”>
<?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar() ) : ?>        <?php endif; ?>

<div>
<ul>
<? if ($children) { ?>
<?php echo $children; ?>
<? }?>
</ul>
</div>


寒林

www.3code.cn 专注WordPress企业主题