List of child pages shortcode
Type [child_pages] on a page to list the pages under it, with links. Keeps overview pages up to date by themselves.
<?php
// [child_pages]
$post = get_post();
if ( ! $post ) {
return '';
}
$list = wp_list_pages(
array(
'child_of' => $post->ID,
'title_li' => '',
'depth' => 1,
'echo' => false,
)
);
return $list ? '<ul class="child-pages">' . $list . '</ul>' : '';
How to use it
Type [child_pages] in a post, a page or a Shortcode block.
In these packs
- Shortcodes: Handy shortcodes for dates, breadcrumbs, buttons, share links, members-only content and more.