Skip to content

Instantly share code, notes, and snippets.

@ebi3102
Created April 4, 2018 16:24
Show Gist options
  • Save ebi3102/231cfce0407e8915cbe53898188c9fdf to your computer and use it in GitHub Desktop.
Save ebi3102/231cfce0407e8915cbe53898188c9fdf to your computer and use it in GitHub Desktop.
Display Child page into Parent Page in WordPress Snippet Code
<!-- Display Child page into Parent Page Snippet Code from
https://y-designs.com/tutorials/wordpress-displaying-subpages-on-pages/-->
<?php $mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
foreach( $mypages as $page ) {
$content = $page->post_content;
if ( ! $content ) // Check for empty page
continue;
$content = apply_filters( 'the_content', $content ); ?>
<?php echo get_the_post_thumbnail( $page->ID , 'sinbadtr-small' ); ?>
<h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2>
<div class="entry"><?php echo $content; ?></div>
<?php } ?>
<!-- end of Display Child page Sinppet Code -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment