Skip to content

Instantly share code, notes, and snippets.

@tinotriste
Last active December 16, 2015 05:58
Show Gist options
  • Save tinotriste/5387872 to your computer and use it in GitHub Desktop.
Save tinotriste/5387872 to your computer and use it in GitHub Desktop.
Wordpress: Display subpages of a page with their custom meta
<?php
$args = array( 'orderby' => 'menu_order', // Allows users to set order of subpages
'order' => 'ASC',
'post_parent' => $post->ID,
'post_type' => 'page',
'post_status' => 'publish'
); $postslist = get_posts($args);
?>
<?php foreach ($postslist as $post) : setup_postdata($post); ?>
<!-- Enter code to display for each subpage here. For example, list items
containing featured thumbnails, page titles and permalinks to the pages.
EXAMPLE BELOW: -->
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); }; ?> </a>
<?php the_excerpt(); ?>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment