• Posted: 2010-12-14
  • Author: Zartgesotten
  • Tags:

List subpages and siblings

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
<?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; ?>

Instructions:

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.


Share this snippet

If you like this snippet, share it with friends!