/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // paste this in functions.php function wpe_highest_ancestor(){ global $post; $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>
Comments
