Current stable release: 0.2.2
1. What’s this for ?
This function can be used as a template tag or, starting with WP 2.5, as a shortcode included in the text to display the list of all the child pages of a page. It will appear as an unordered list of titles and links to the pages and an optional text.
2. Requirements
- WordPress: List Child Pages requires at least WP 2.1 (or up). It is compatible with all versions of WordPress up to the latest release (2.9.2).
3. Installation
- Download the file.
- Copy the file .php in your
pluginsdirectory. - Enable the plugin in the Administration >> Plugins section.
- Modify the appropriate theme’s files and add the dlo_list_child_pages() function with its parameters or insert the shortcode [ dlo_lcp ] and its attributes in the text of a page.
(Note: if you are upgrading from a previous install, simply overwrite the older files with the new ones in the instructions above.)
4. Documentation
4.1 Using the template tag
After copying the file, the dlo_list_child_pages() is available for use in the templates.
The parameters are:
- postID: The page ID whose child pages are to be displayed.
- args: A string of characters containing the selection and display criterias for the list. The string is in the form: keyword1=value1&keyword2=value2
- Possible keywords:
- numberposts: An integer representing the max. number of pages to display (default=5).
- offset : An integer representing the n first pages to skip (default=0).
- text_opt : Display options for the child post text. Possible values:
- NONE : No text, display title only. (Default value)
- EXCERPT : The 50 first words are displayes. The text is ended by [...] indicating that there is more to read clicking on the title.
- CONTENT : The whole text is displayed after the title. If the tag <!–more–> is included in the text, the display will be cut there. End of the text will be available clicking on the link (more…) at the end of the text.
- orderby: Order criteria. Possible values are:
- post_date : by publication date (default value).
- post_modified : by modification date.
- post_title : by title.
- ID : by page ID.
- post_author : by author.
- post_name : by page slug.
- order: Ordre value. Possible values:
- ASC : Ascendant order.
- DESC: Descendant order (default value).
- echo: Possible values:
- true : The resulting list is displayed (echoed) to screen (default value).
- false: The resulting list is returned by the function.
The function will returned an unordered list enclosed in div tags (with id = “dlo_post_list”) that can be styled with CSS.
Things must be done like this:
1) Create a template file like this one:
<?php
/*
Template Name: Page with sons
*/
?>
<?php get_header(); ?>
<p id="content" class="narrowcolumn">
<?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 »</p>'); ?>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
</div>
<?php dlo_list_child_pages($post->ID, 'text_opt=CONTENT') ?>
<?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '<p>', '<p>'); ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
2) Write a page and give it “page with sons” as page model in the visual editor.
3) Then, all pages declared as child of the one created before will be displayed in the mother page.
The plugin in action can be seen on the page “WordPress” of this site. The function used is, in this case, dlo_list_child_pages($post->ID, ‘text_opt=EXCERPT’) to display an extract of the text below the title.
4.2 Using the shortcode [ dlo_lcp ]
After copying the file on WordPress 2.5 or more, the shortcode is available and can be inserted in the text of a page as [ dlo_lcp attribute1="value1" attribute2="value2" ].
Available attributes are:
- id: The page ID whose child pages are to be displayed.
- numberposts: An integer representing the max. number of pages to display (default=5).
- offset : An integer representing the n first pages to skip (default=0).
- text_opt : Display options for the child post text. Possible values:
- NONE : No text, display title only. (Default value)
- EXCERPT : The 50 first words are displayes. The text is ended by [...] indicating that there is more to read clicking on the title.
- CONTENT : The whole text is displayed after the title. If the tag <!–more–> is included in the text, the display will be cut there. End of the text will be available clicking on the link (more…) at the end of the text.
- orderby: Order criteria. Possible values are:
- post_date : by publication date (default value).
- post_modified : by modification date.
- post_title : by title.
- ID : by page ID.
- post_author : by author.
- post_name : by page slug.
- menu_order: by page order.
- order: Ordre value. Possible values:
- ASC : Ascendant order.
- DESC: Descendant order (default value).
The function will return an unordered list enclosed in div tags (with id = “dlo_post_list”) that can be styled with CSS.
Things must be done like this:
1) Write a page A.
2) Write a page B and give it page A as page parent.
3) Write a page C and give it page A as page parent.
4) Modify the text of page A and include the shortcode where the list of its child pages must appear. Example:
[ dlo_lcp text_opt="EXCERPT" orderby="post_title" order="ASC" ] will create the child pages list of the current page ordered by page title.
5) Then, all pages declared as child of the one created before will be displayed in the mother page.
5. History
V.0.2.2
Bug corrected to save/restore the ID of the current post
V. 0.2.1
Bug corrected to allow more than 5 child pages to be displayed when using the shortcode [ dlo_lcp ]
V. 0.2.0
Using a WP 2.5 new feature, it’s now possible to insert the shortcode within a page’s text to get the list of child pages.
V. 0.1.0
Initial version


30 Comments
Pages: [4] 3 2 1 » Show All
Merci pour ton plugin que j’ai mis sur mon site mcmadort
sauf erreur de ma part … lorsqu’on utilise CONTENT pour le text_opt en template tag … ça ne s’arrette pas a la balise more ? mais prend tout le contenu … c’est moi ou bien ?
Quid de la 2.7 ? est-ce compatible ?
J’ai l’impression orderby’ => ‘menu_order’, n’est pas possible avec le template tag … est-ce normal ?
@Nico … yeahh … Genial … grace a cette astuce tu complète parfaitement ce plugin … et wordpress devient enfin … un CMS … avec une fonction de sommaire automatique complète \o/ MERCI !
j’ai commencé a l’installé sur ce site en construction : http://www.kit-a-se-marier.fr
(utilisé pour le sommaire sur l’accueil et sur les page de rubrique)
@yumiam : En installant le plugin YAPB, qui permet d’associer une image à un post/page, tu peux y arriver.
Une fois YAPB installé, rajoute dans la fonction dlo_list_posts, les 2 lignes (lignes 28-29 pour LCP 0.2.1) :
$img= yapb_get_image(”, array(’alt’ => ‘Vignette illustrant ‘ . get_the_title() . ”), ”);
$result = $result . ‘<li><a href=”‘ . get_permalink() . ‘”>’ .$img.’<span>’ . get_the_title() . ‘</span></a><p>’.($text_opt == ‘EXCERPT’ ? get_the_excerpt() : ($text_opt == ‘CONTENT’ ? get_the_content() : ”)) . ‘</p></li>’;
wouahou … depuis le temps que je cherche un truc qui fait ça … enfin … merci et bravo !
as tu une une idée pour ça ?
j’ai retrouvé le post sur le forum de wordpress fr sur lequel j’avais posté la question initialement qui m’a conduit ici …
Maintenant le top serait de pouvoir ajouter une vignette a chaque élément du listing pour rendre le sommaire plus visuel … en utilisant un champ personnalisé …
Wonderful! Thank you so much for this – it was exactly what I was looking for.
Thank you for this wonderful plugin!!
Mike,
Il se peut que le problème vienne d’une mauvaise syntaxe pour les guillemets simples qui entourent cette partie (‘text_opt=CONTENT’) de l’instruction:
<?php dlo_list_child_pages($post->ID, ‘text_opt=CONTENT’) ?>
Il faudrait retaper ces guillemets au clavier pour être sûr qu’il ne s’agit pas d’un autre caractère parasite.
Cordialement
Pages: [4] 3 2 1 » Show All