Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. $args = array(
  2. 'post_parent' => $post->ID,
  3. 'post_type' => 'page',
  4. 'post_status' => 'any'
  5. );
  6. $children = get_posts( $args );
  7. // $children = get_children( $args ); //this also works,btw
  8.  
  9. foreach($children as $child){
  10. setup_postdata( $child );
  11. echo "<h1>" . $child->post_title . "</h1>";
  12. }
  13.  
  14. $args = array(
  15. 'post_parent' => $post->ID,
  16. 'post_type' => 'page',
  17. // 'numberposts' => -1,
  18. 'post_status' => 'any'
  19. );
  20. $child_pages_query= new WP_Query(args);
  21. // echo $child_pages_query->post_count; // wrong answer already!
  22. if ($child_pages_query->have_posts()){
  23. while($child_pages_query->have_posts()){
  24. $child_pages_query->the_post();
  25. echo "<h1> " . $post->post_title . " </h1>";
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement