sectioned-page WordPress Page Template
use this code on my site to display my projects page, which essentially is an intro paragraph (the contents of the Project WordPress page), followed by the children page listed within the same view.
For me this means that all of my projects can be listed on one page but edited separately. It could also be used to aid writing an article by splitting it into sections.
This does come with limitations:
- No pagination – I don’t think it will work if page 2 or more is requested.
- No REAL Child pages – as you are already displaying them, although they can be viewed as single pages themselves.
- Duplicated content – The same / similar information is available in more than one location
But without further ado – the code:
<?php /* Start the Main Loop. */?> <?php $post_parent=0; //Declaring it out of the loop for use later (might not be needed) ?> <?php while ( have_posts() ) : the_post(); ?> <?php /* Display the single page. */ ?> <article class=""> //code for diplaying the holding page - maybe an intro? or blank... </article> <?php $post_parent= the_ID(); //Setting it to the current post/page ID ?> <?php endwhile; // End the main loop. Carrying the $post_parent through; ?> <?php query_posts('post_type=page&post_parent='.$post_parent); //post_parent used to query just children ?> <?php /* Start the child Loop. */?> <?php while ( have_posts() ) : the_post(); ?> <?php /* How to display all child pages. */ ?> <article class=""> //code for diplaying the small pages/sections </article> <?php endwhile; // End the child loop. ?>