Current Release: 1.10 (download) – Released on May 26th 2008
What it does
This plugin allows you to run loops within your WordPress templates where you query for children of the current page.
How it works
The plugin adds an extra arguments to the list of arguments supported by query_posts().
The query argument `child_of` is used to add a WHERE to the database query to limit the pages returned to those with a post_page equal to the argument provided.
The query argument `child_limit` is used to limit the number of pages returned.
The query argument `child_offset` is used to offset the limiting to allow for pagination if required.
Requirements
This plugin has been tested with WordPress v2.8-beta and should work with all WordPress versions that support pages (v2.0 and later).
Usage Example
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><em><?php the_excerpt(); ?></em></dt>
<?php endwhile; endif; ?>
</dl></div>
More detailed usage examples can be found in this article “Searching for Children and Grandchildren”
Download
The latest version of the plugin may be downloaded here: pjw-query-child-of.1.10.zip
Comments are closed.