How to Display Sub page of a Parent page in WordPress

How to Display Sub page of a Parent page in WordPress

How to Display Sub page of a Parent page in WordPress

How to Display Sub page of a Parent page in WordPress :

Sub page links in main pages

Using the following code your can display sub page of a parent page in wordpress. The result s displayed in a <li> list with hyper link to those pages. This code is perfect for sidebar of inner pages if you want display sub-page of current page.

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