How to get a list of child pages of the current page in the WordPress.Only you have to call to wordpress wp_list_pages core function to get child pages.No display errors and no need to write sql statements.
1 2 3 4 5 6 7 8 9 10 |
<?php $currentPageID = $post->ID; //current page ID $children = wp_list_pages('title_li=&child_of='.$currentPageID.'&echo=0'); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?> |
Note:
Get parent page ID
1 |
$post->post_parent; |
Get Current page ID
1 |
$post->ID; |