By
05/13/2016   Comments Off on List all the children of parent page

View all snippets

When you visit the parent page, it will list all its children. Visiting the child page of the parent will show its siblings.

<?php if($post->post_parent)
   $children = wp_list_pages("sort_column=menu_order&title_li=&depth=1&child_of=".$post->post_parent."&echo=0");
   else $children = wp_list_pages("sort_column=menu_order&title_li=&depth=1&child_of=".$post->ID."&echo=0");
   if ($children): ?>
   <ul>
     <?php echo $children; ?>
   </ul>
<?php endif; ?>