此頁面上的部分答案略有過時的信息。即使用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