Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $args = array(
- 'post_parent' => $post->ID,
- 'post_type' => 'page',
- 'post_status' => 'any'
- );
- $children = get_posts( $args );
- // $children = get_children( $args ); //this also works,btw
- foreach($children as $child){
- setup_postdata( $child );
- echo "<h1>" . $child->post_title . "</h1>";
- }
- $args = array(
- 'post_parent' => $post->ID,
- 'post_type' => 'page',
- // 'numberposts' => -1,
- 'post_status' => 'any'
- );
- $child_pages_query= new WP_Query(args);
- // echo $child_pages_query->post_count; // wrong answer already!
- if ($child_pages_query->have_posts()){
- while($child_pages_query->have_posts()){
- $child_pages_query->the_post();
- echo "<h1> " . $post->post_title . " </h1>";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement