此页面上的部分答案略有过时的信息。即使用child_of
时,似乎不再需要exclude
。
这里是我的解决方案:
// if this is a child page of another page,
// get the parent so we can show only the siblings
if ($post->post_parent) $parent = $post->post_parent;
// otherwise use the current post ID, which will show child pages instead
else $parent = $post->ID;
// wp_list_pages only outputs <li> elements, don't for get to add a <ul>
echo '<ul class="page-button-nav">';
wp_list_pages(array(
'child_of'=>$parent,
'sort_column'=>'menu_order', // sort by menu order to enable custom sorting
'title_li'=> '', // get rid of the annoying top level "Pages" title element
));
echo '</ul>';
对于这个问题最好的解决办法IMO – benpalmer 2012-01-05 11:06:06