Return to Snippet

Revision: 22262
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);
        $child_of = $page_ancestors;
        $child_of = $post->ID;
    return $child_of;

This is for the template
<ul class="sidebar">
  <?php wp_list_pages('child_of=' . wpe_highest_ancestor()); ?>

If you want to have the name of the top-level page in the sidebar, you can use the following code:
<ul class="sidebar">
  $child_of = wpe_highest_ancestor();

Initial URL

Initial Description

Initial Title
Wordpress : Display Always All Subpages in Sidebar

Initial Tags
wordpress, Development

Initial Language