How Can I Add Content of Child Pages to a Page
-
I am trying to display a few child pages within a single page (not the parent page). I want all the content of the child pages, titles included, to show on one page. Not a list and not excerpts. I have tried a few different php codes none of which worked.
I tried this tutorial which worked great for parent pages but not child pages.
And I found this on Codex
<?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 ); ?> <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 } ?>
but I don’t want it to display on parent page. I need it to display on a new page.
Also, in the above code I know this is probably a simple thing but where do I list the page id’s?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How Can I Add Content of Child Pages to a Page’ is closed to new replies.