title: Sidebar list: If current page is deepest level child, display sibling pages. If not, display child pages
body: <p>I'm making a sidebar that will display sibling pages if the current page is the deepest level child, and only child pages if it is not. This is as far as I've gotten, I haven't been able to figure out the logic to complete it. Any ideas? Thank you in advance.</p>
  
  <pre><code>global $post; 
      if ( is_page() &amp;&amp; $post-&gt;post_parent )
          $childpages = wp_list_pages( 'sort_column=menu_order&amp;title_li=&amp;child_of=' . $post-&gt;post_parent . '&amp;echo=0' );
      else
          $childpages = wp_list_pages( 'sort_column=menu_order&amp;title_li=&amp;child_of=' . $post-&gt;ID . '&amp;echo=0' );
      if ( $childpages ) {
          $interior_sidebar = '&lt;ul class="child-pages"&gt;' . $childpages . '&lt;/ul&gt;';
      }
  </code></pre>