Revision: 22262
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 7, 2010 07:48 by crs
Initial Code
<?php // paste this in functions.php
function wpe_highest_ancestor(){
global $post;
$page_ancestors = end($post->ancestors);
if(!empty($page_ancestors)){
$child_of = $page_ancestors;
}else{
$child_of = $post->ID;
}
return $child_of;
}
?>
This is for the template
-------------------------------
<ul class="sidebar">
<?php wp_list_pages('child_of=' . wpe_highest_ancestor()); ?>
</ul>
If you want to have the name of the top-level page in the sidebar, you can use the following code:
<ul class="sidebar">
<?php
$child_of = wpe_highest_ancestor();
wp_list_pages('child_of='.$child_of.'&title_li=<h5>'.esc_attr(get_the_title($child_of)).'</h5>');
?>
</ul>
Initial URL
Initial Description
Initial Title
Wordpress : Display Always All Subpages in Sidebar
Initial Tags
wordpress, Development
Initial Language
PHP