Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ul>
- <?php $all = get_pages();
- foreach($all as $all) {
- if($all->post_parent) {
- if( get_page($all->post_parent)->post_parent ) {
- $tp = get_page($all->post_parent);
- if( !get_page( $tp->post_parent )->post_parent) { $grandchild_ids[] = $all->ID; }
- }
- }
- }
- $args = array(
- 'post_type' => 'page',
- 'post_status' => 'publish',
- 'posts_per_page' => 5,
- 'orderby' => 'rand',
- 'post__in' => $grandchild_ids
- );
- $my_query = null;
- $my_query = new WP_Query($args);
- if( $my_query->have_posts() ) {
- while ($my_query->have_posts()) : $my_query->the_post(); ?>
- <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
- <?php endwhile;
- }
- wp_reset_query(); ?>
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement