Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

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.

  • Type PHP
  • Runs Where you put the [child_pages] shortcode
  • Category Shortcodes
  • Tested with WordPress 7.1
PHP
<?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.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.