WordPress.org

Ready to get started?Download WordPress

Plugin Directory

!This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

PJW Query Child Of

Allows you to use query_posts to list the children of a page.

How can I use this in a page template?

The plugin is used when you call query_posts() from a theme template file so as to run your own query.

The following code is an example of what you could do to generate a list of the first 10 child pages from a parent page:

<div id="children">
        <dl>
        <?php query_posts('static=true&child_limit=10&child_of='.$id.'&order=ASC'); ?>
        <?php if(have_posts()) : while (have_posts()) : the_post(); ?>
        <dt><a href="<?php the_permalink();?>"><?php the_title();?>:</a></dt>
                <dd style=""><em><?php the_excerpt(); ?></em></dd>
        <?php endwhile; endif; ?>
        </dl>
</div>

How can I create a a page template which lists children of children?

If you want to create a hierarchical display with children of children then you will need to use nested loops which requires some care.

You will need to have the most up-to-date version of this plugin and then you can use the examples which are included with it in the page-templates folder.

The basic loops needed for a nested solution are as follows:

<div id="children">
        <dl>
        <?php query_posts('static=true&posts_per_page=-1&post_parent='.$id.'&order=ASC'); ?>
        <?php if(have_posts()) : while (have_posts()) : the_post(); ?>
        <?php    $inner_query = new WP_Query("post_type=page&posts_per_page=-1&post_parent={$id}&order=ASC");
                while ($inner_query->have_posts()) : $inner_query->the_post(); ?>
                    <dt><a href="<?php the_permalink();?>"><?php the_title();?>:</a></dt>
                    <dd style=""><em><?php the_excerpt(); ?></em></dd>
        <?php endwhile; endwhile; endif; ?>
        </dl>
</div>

How do I set an excerpt for a Page?

If you want to set an excerpt for a page then you need to install my Page Excerpt plugin and this will add an excerpt box to the "Edit Page" so that you can enter one.

This plugin can be found here: http://wordpress.org/extend/plugins/pjw-page-excerpt/

Requires: 2.0 or higher
Compatible up to: 3.1.4
Last Updated: 2011-3-30
Downloads: 3,698

Ratings

4 stars
4.8 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,2,2
100,1,1
100,1,1