<?php
if ($post->post_parent) { //We are a child, print out sub menu
wp_list_pages( array(\'title_li\'=>\'\',\'include\'=>$post->post_parent) );
wp_list_pages( array(\'title_li\'=>\'\',\'depth\'=>1,\'child_of\'=>$post->post_parent) );
}
//We are not a child but do we have children
$children = wp_list_pages(array(\'child_of\' => $post->ID, \'echo\' => 0));
if ( !empty($children) ) {
//If so print out the sub menu
wp_list_pages( array(\'title_li\'=>\'\',\'include\'=>$post->ID) );
wp_list_pages( array(\'title_li\'=>\'\',\'depth\'=>1,\'child_of\'=>$post->ID) );
}
//Not a child and not a parent so show nothing and continue
?>
我对此进行了测试,正如您所提到的那样,我无法理解该函数,但也许有人可以使用该函数发布更好的解决方案。