Skip to content

Instantly share code, notes, and snippets.

@brianfryer
Created May 7, 2013 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianfryer/5536893 to your computer and use it in GitHub Desktop.
Save brianfryer/5536893 to your computer and use it in GitHub Desktop.
A snippet to display child pages of the current page for WordPress.
<?php
if ( have_posts() ) while ( have_posts() ) : the_post();
endwhile;
$childArgs = array(
'post_parent' => $post->ID,
'post_type' => 'page',
'posts_per_page' => '-1',
'orderby' => 'menu_order',
'order' => 'ASC'
);
$child = new WP_Query($childArgs);
if ($child->have_posts()) : while ($child->have_posts()) : $child->the_post();
?>
<section class="hero">
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
</section>
<?php endwhile; endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment