Skip to content

Instantly share code, notes, and snippets.

@jbd91
Last active February 2, 2018 03:48
Show Gist options
  • Select an option

  • Save jbd91/384c192e2c6ccd9273aa904b21983226 to your computer and use it in GitHub Desktop.

Select an option

Save jbd91/384c192e2c6ccd9273aa904b21983226 to your computer and use it in GitHub Desktop.
WP Query - Children of Parent Page
<?php
$args = [
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' => $post->ID,
'order' => 'ASC',
'orderby' => 'menu_order'
];
$parent = new WP_Query( $args );
if ( $parent->have_posts() ) : ?>
<?php while ( $parent->have_posts() ) : $parent->the_post(); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment