這裏有一個簡單的方法,將在你的側邊欄工作:
<?php
$page_id = $post->ID;
$page_parent = $post->post_parent;
if ($page_parent) { // there's a parent page, get the children
$args = array(
'parent' => $page_parent,
'child_of' => $page_parent,
'hierarchical' => 0,
'sort_column' => 'menu_order'
);
}
else { // no parent, so just get top level pages
$args = array(
'parent' => 0,
'sort_column' => 'menu_order'
);
}
$my_pages = get_pages($args);
while ($page = current($my_pages)) { // find this page's position in the page array
if ($page->ID == $page_id) {
echo key($my_pages) + 1;
}
next($my_pages);
}
$result = count($my_pages);
echo " of " . $result;
?>
這會不會得到更好的在wordpress.stackexchange.com問? –
不知道該網站。謝謝! – Kanonskall