I have a parent page called services with children, each service child has child pages within it.
On the first level child page i want to show all of the pages below it in. When i click through to one of those pages, i want that same menu to display, with all of the pages that are the same level as the one i am on showing.
i currently have this code:
global $post;
$subpages = wp_list_pages( array(
'echo'=>0,
'title_li'=>'',
'depth'=>1,
'child_of'=> ( $post->post_parent == 0 ? $post->ID : $post->post_parent)
));
if ( !empty($subpages) ) {
?>
<div class="services-sub-menu">
<?php
if ( $post->post_parent != 0 ) {
echo '<p class="parent-link"><a href="'. get_permalink($post-
>post_parent) .'"><em>'. __('Back to') .' '. get_the_title($post-
>post_parent) .'</em></a><p>';
}
echo '<ul>';
echo $subpages;
echo '</ul>';
?>
</div>
<?php
} else {
}
This works in that is shows the current level sub items. However, on first level children i want to show the children below, on second level children i want to show children on the same level.
Thankyou in advance for your help, much appreciated.