Skip to content

Instantly share code, notes, and snippets.

@justinwhall
Created March 8, 2012 01:23
Show Gist options
  • Save justinwhall/1997825 to your computer and use it in GitHub Desktop.
Save justinwhall/1997825 to your computer and use it in GitHub Desktop.
PHP: WordPress | Get children pages AND the sibling pages ONLY when on child pages
<?php
// Get children pages AND the sibling pages ONLY when on child pages
if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&sort_column=menu_order&depth=1");
else
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&sort_column=menu_order&depth=1");
if ($children) :
?>
<div id="child-menu" >
<ul>
<?php echo $children; ?>
</ul>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment