Use this WP function get_pages() and get_page_children()
function get_child_pages( $parent_page_ID ){
$all_pages = get_pages( array( 'post_type'=> 'page' ) );
$child_pages = get_page_children( $parent_page_ID, $all_pages );
if( !empty( $child_pages ) ){
$html .= '<ul>';
foreach ( $child_pages as $key => $child_page ) {
$html .= '<li>'.$child_page->post_title;
get_child_pages( $child_page->ID );
$html .= '</li>';
}
$html .= '</ul>';
}
return $html;
}
function list_pages(){
$html="";
if ( $post->post_parent ) {
$parent = $post->post_parent;
}else{
$parent = $post->ID;
}
$parent_pages = get_pages( array( 'parent' => $parent, 'post_type'=> 'page' ) );
$html.= '<ul>';
foreach ( $parent_pages as $parent_page ) {
$html .= '<li>'.$parent_page->post_title;
$html .= get_child_pages( $parent_page->ID );
$html .= '</li>';
}
$html.= '</ul>';
return $html;
}
add_shortcode( 'list_pages', 'list_pages' );