Guest User

Wordpress - Display grandchild pages of current page

a guest
Sep 18th, 2013
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.53 KB | None | 0 0
  1. <?php
  2.                                 $postid = $post->ID;
  3.                                 $args = array(
  4.                                 'post_type' => 'page',
  5.                                 'post_status' => 'publish',
  6.                                 'orderby' => 'date',
  7.                                 'order'=> 'DESC',
  8.                                 'posts_per_page' => -1,
  9.                                 'post_parent' => $postid,
  10.                                 );
  11.                                 $child_level = get_posts($args);
  12.                                 if($child_level) :
  13.                                 foreach($child_level as $child_page) :
  14.                                  
  15.                                 $args = array(
  16.                                 'post_type' => 'page',
  17.                                 'post_status' => 'publish',
  18.                                 'orderby' => 'date',
  19.                                 'order'=> 'DESC',
  20.                                 'posts_per_page' => -1,
  21.                                 'post_parent' => $child_page->ID
  22.                                 );
  23.                                 $my_query = null;
  24.                                 $my_query = new WP_Query($args);
  25.                                 if( $my_query->have_posts() ) {
  26.                                
  27.                                 while ($my_query->have_posts()) : $my_query->the_post(); ?>
  28.                                                                
  29.                                 <div class="product-box">
  30.                                     <div class="product-content">
  31.                                         <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
  32.                                         <div class="productimg"><?php the_post_thumbnail('thumbnail'); ?></div>
  33.                                         <p><?php echo excerpt(15); ?></p>
  34.                                         <p class="p-more"><a href="#product-<?php the_id(); ?>">More</a></p>
  35.    
  36.                                         <div class="product-details">
  37.                                             <div class="pd-col">
  38.                                                 <p class="price">P<?php echo $cfs->get('prod_price', $pageChild->ID); ?></p>
  39.                                                 <!--<p class="rating"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rate0.png"></p>-->
  40.                                                 <p class="rating"><?php if(function_exists('the_ratings')) { the_ratings(); } ?></p>
  41.                                             </div>
  42.                                             <div class="pd-col">
  43.                                                 <a href="<?php the_permalink(); ?>"><div class="buyicon"></div></a>
  44.                                             </div>
  45.                                         </div><!-- product-details -->
  46.                                     </div>
  47.                                 </div><!-- product-box -->
  48.                                
  49.                                 <?php endwhile;
  50.                                 }
  51.                                 wp_reset_query();
  52.                                  
  53.                                 endforeach;
  54.                                 endif;
  55.                                 ?>
  56.                         </div>
Advertisement
Add Comment
Please, Sign In to add comment