Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karks88/c7385402d96aa99fa01620fb54b2371e to your computer and use it in GitHub Desktop.
Save karks88/c7385402d96aa99fa01620fb54b2371e to your computer and use it in GitHub Desktop.
This script will look at the current page and serve up a list of sibling pages.
<?php
// Show child or sibling pages in left column.
if(!$post->post_parent){
// will display the subpages of this top level page
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&sort_column=menu_order");
}
else{
if($post->ancestors) {
// now you can get the the top ID of this page
// wp is putting the ids DESC, thats why the top level ID is the last one
$ancestors = end($post->ancestors);
$children = wp_list_pages("title_li=&child_of=".$ancestors."&echo=0&sort_column=menu_order");
}
}
if ($children) { ?>
<div class="sidebarnav">
<p><strong>Inside This Section:</strong></p>
<div class="textwidget">
<ul class="sidebar-menu-choices">
<?php echo $children; ?>
</ul>
</div>
</div>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment