Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
List Child Pages
Plugin Name: Steph's Tiny List Child Pages Plugin
Plugin URI:
Description: Lets you list child pages using a shortcode. Also displays child page list by default on empty parent pages.
Author: Stephanie Leary
Version: 1.0
Author URI:
License: GPL v2 or later
// note depth = 0 (no hierarchy)
function scl_child_pages_shortcode() {
$id = get_the_ID();
return '<ul class="childpages">'.wp_list_pages( 'echo=0&depth=0&title_li=&child_of='.$id ).'</ul>';
add_shortcode( 'child-pages', 'scl_child_pages_shortcode' );
add_shortcode( 'children', 'scl_child_pages_shortcode' );
add_shortcode( 'subpages', 'scl_child_pages_shortcode' );
// note no depth argument (full hierarchy)
function scl_append_child_pages( $content ) {
$children = '';
if ( is_page() && ( empty($content) ) ) {
$id = get_the_ID();
$children = '<ul class="childpages">'.wp_list_pages( 'echo=0&title_li=&child_of='.$id ).'</ul>';
return $content.$children;
add_filter( 'the_content', 'scl_append_child_pages' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment