List subpages and siblings

This is kind of a section navigation. It displays the current page’s subpages and siblings, if there are any.

Should work anywhere in your theme.

Code Snippet:

<?php
global $wp_query;
if( empty($wp_query->post->post_parent) ) {
    $parent = $wp_query->post->ID;
}
else {
    $parent = $wp_query->post->post_parent;
} ?>
<?php if(wp_list_pages("title_li=&child_of=$parent&echo=0" )): ?>
<div id="submenu">
    <ul>
        <?php wp_list_pages("title_li=&child_of=$parent" ); ?>
    </ul>
</div>
<?php endif; ?>

Posted in Pages