Advertisement
wardhanarizaldi

WP Display child pages

Jun 2nd, 2021
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1.     <?php
  2.         $subpages = new WP_Query( array(
  3.             'post_type' => 'page',
  4.             'post_parent' => $post->ID,
  5.             'posts_per_page' => -1,
  6.             'orderby' => 'menu_order'
  7.         ));
  8.     ?>
  9.        
  10.        
  11.     <?php if( $subpages->have_posts() ) : ?>
  12.  
  13.         <?php while( $subpages->have_posts() ) : $subpages->the_post(); ?>
  14.  
  15.             <div>
  16.                 <?php the_title();?>
  17.             </div>
  18.  
  19.         <?php endwhile; ?>
  20.  
  21.     <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement