sectioned-page WordPress Page Template

I use preivously used 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:

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. ?>
comments powered by Disqus