Advertisement
alchymyth

grandchild pages only

Apr 8th, 2011
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <ul><?php
  2. $postid = $post->ID;
  3. $args = array(
  4. 'post_type' => 'page',
  5. 'post_status' => 'publish',
  6. 'orderby' => 'rand',
  7. 'posts_per_page' => -1,
  8. 'post_parent' => $postid
  9. );
  10. $child_level = get_posts($args);
  11. if($child_level) :
  12. foreach($child_level as $child_page) :
  13.  
  14. $args = array(
  15. 'post_type' => 'page',
  16. 'post_status' => 'publish',
  17. 'orderby' => 'rand',
  18. 'posts_per_page' => -1,
  19. 'post_parent' => $child_page->ID
  20. );
  21. $my_query = null;
  22. $my_query = new WP_Query($args);
  23. if( $my_query->have_posts() ) {
  24. while ($my_query->have_posts()) : $my_query->the_post(); ?>
  25. <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
  26. <?php endwhile;
  27. }
  28. wp_reset_query();
  29.  
  30. endforeach;
  31. endif;
  32. ?></ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement