Forums

How to generate a list of subpages ON a Page? (2 posts)

  1. billdennis5
    Member
    Posted 3 years ago #

    If I wanted every single page to include a list of subpages for that page alone, where would I find that code? I've been looking all over the place.

    Thanks in advance.

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    In a Page Template (I ripped wp-content/themes/default/page.php) with a loop showing the parent page content:

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    /*
    Template Name: ChildPages
    */
    ?>
    
    <?php get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    <?php
    
    ?>
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<h2><?php the_title(); ?></h2>
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;
    '); ?>
    
    				<?php wp_link_pages(array('before' => '<strong>Pages:</strong> ', 'after' => '
    ', 'next_or_number' => 'number')); ?>
    			</div>
    		</div>
    <?php
    $wlp=wp_list_pages('echo=0&child_of=' . $post->ID . '&title_li=');
    if ( !empty( $wlp ) ) {
    echo $wlp;
    }
    ?>
    		<?php endwhile;  ?>
    
    <?php		endif; ?>
    
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic