I want to list all sub-pages only one level though of one particular page. I was reading Function Reference/get pages and thought that $pages = get_pages( array( 'child_of' => $post->ID, 'parent' => $post->ID)) ;
will do the trick but it is not working. It lists all pages on the same level like the page I call that code from. If I omit parent option I will get all pages even with sub-pages that I want. But I want only
sub-pages.
The whole function is like
function about_menu(){
if (is_page('about')){
$pages = get_pages( array( 'child_of' => $post->ID, 'parent' => $post->ID)) ;
foreach($pages as $page)
{
?>
<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
<?php
}
}
}
below are screen shots from wp admin and results. Mine is second one
Screen shot from WP admin http://img687.imageshack.us/img687/6139/e2568e8ec2684e7aa1bb3d1.png and the result http://img269.imageshack.us/img269/2365/329c5097c78f4d3186a177c.png
Check out
wp_list_pages()
. I think these settings will give you what you want.try adding
right before you declare $pages.