Want more features on Pastebin? Sign Up, it's FREE!
Guest

WordPress Child Pages Loop

By: a guest on Aug 25th, 2011  |  syntax: PHP  |  size: 0.49 KB  |  views: 214  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. // Main loop
  3.  
  4. if ( have_posts() ) while ( have_posts() ) : the_post();
  5.  
  6.         // Parent (current) page loop
  7.  
  8. endwhile;
  9.  
  10. // Child pages loop
  11.  
  12. $childargs = array(
  13.         'post_parent' => $post->ID,
  14.         'post_type' => 'page',
  15.         'posts_per_page' => '-1',
  16.         'orderby' => 'menu_order',
  17.         'order' => 'ASC'
  18. );
  19.  
  20. $child = new WP_Query($customargs);
  21.  
  22. if ($child->have_posts()) : while ($child->have_posts()) : $child->the_post();
  23.  
  24.         /// Loop through child pages of current page
  25.  
  26. endwhile; endif;
  27.  
  28. ?>
clone this paste RAW Paste Data