List Child Pages Shortcode
List a page's child pages anywhere with one shortcode, with optional featured images, excerpts, custom ordering, and CSS classes.
Install in
List Child Pages Shortcode adds a [listchildpages] shortcode that lists the child pages of the current page, or of any page you choose, as a simple linked list. Each item can show the page’s featured image and excerpt.
- Works in any page, post, widget, or template that renders shortcodes.
- Choose the parent by ID, slug/path, or the current page.
- Sort by date, title, menu order (the Order field under Page Attributes), and more.
- Optional featured images at any registered image size.
- Add your own CSS classes to the list, items, and links.
- No settings, no database tables, no external services, no tracking.
Usage
The shortcode is [listchildpages]...[/listchildpages]. [dknm_list_child_pages] works the same way. It accepts several attributes:
- ifempty: Message or HTML to show if no child pages exist.
- order:
ASCorDESC. Default:DESC, orASCwhenorderby="menu_order". - orderby: Field to order by. Default:
publish_date(maps todate). Also acceptspublished(maps todate),title,name,modified,menu_order,ID,rand,type, andauthor. Usemenu_orderto follow the Order numbers set under Page Attributes; pages with the same number sort by title. - displayimage: Show featured image (
yes|no). Also acceptsy,true,1, andon. Default:no. - align: CSS class to apply to the image (
alignleft,alignright, etc.). - ulclass, liclass, aclass: CSS classes for the list, list items, and links.
- parent: ID, slug/path, or
currentto choose the parent page. Default:current. - size: Image size for thumbnails (
thumbnail,medium,large,full, or custom size). Default:thumbnail.
Examples:
Example 1: Order the child pages by publish date in descending order:
[listchildpages aclass="" ifempty="No child pages" orderby="publish_date" order="desc" displayimage="no"]
<h3>Here are our child pages:</h3>
[/listchildpages]
Example 2: Order the child pages by title in ascending order with the page’s featured image aligned left:
[listchildpages orderby="title" order="asc" displayimage="yes" align="alignleft"]
<h3>Here are our child pages:</h3>
[/listchildpages]
Example 3: Target a specific parent page by ID and use medium-sized images:
[listchildpages parent="123" displayimage="yes" size="medium"]
<h3>Resources</h3>
[/listchildpages]
Example 4: Target a parent page by slug and show full-size featured images:
[listchildpages parent="about/company" displayimage="yes" size="full"]
<h3>Team Sections</h3>
[/listchildpages]
Example 5: Follow the page order set under Page Attributes:
[listchildpages orderby="menu_order"]
<h3>Chapters</h3>
[/listchildpages]
Example 6: Explicitly set the parent as the current page and use large images:
[listchildpages parent="current" displayimage="yes" size="large"]
<h3>Subpages</h3>
[/listchildpages]
Developer filters
dknm_lcp_html– filter the final HTML. Receives the HTML, the parent page ID, and the normalized attributes.shortcode_atts_listchildpages– the standard WordPress filter for the shortcode’s attributes.dklcp/listchildpages/html– the 1.x output filter. It still runs but is deprecated; usedknm_lcp_html.
Built by DK New Media. Visit Martech Zone for updates on this plugin and other marketing tools.
Written by Joobi from the project's own listing. See the source page
1.6.3
- Author, documentation, donate, and readme links now include campaign tracking. The Martech Zone link points at the plugin’s documentation article.
1.6.2
- New WordPress.org banner and animated icon, with a consistent DK layout and a “Developed by Martech Zone” badge.
- Add uninstall.php to defensively remove any leftover plugin options or transients (the plugin does not store any).
1.6.1
- Readme: fix code example formatting on WordPress.org.
1.6.0
- Author is now DK New Media. The plugin name, slug, folder, main file, and
[listchildpages]shortcode are unchanged. - Fix:
orderby="menu_order"now sorts ascending (the Page Attributes order) when noorderis given, with title as a tie-breaker for pages that share a number. - New:
[dknm_list_child_pages]alias for the shortcode. - New:
dknm_lcp_htmloutput filter. The 1.xdklcp/listchildpages/htmlfilter still runs and is marked deprecated. - Code now uses the
dknm_lcp_prefix. The olddklcp_function names remain as wrappers. - Tested up to WordPress 7.1 (7.1.5). Requires WordPress 4.6 or later.
1.5.1
- Align Version and Stable tag so WordPress.org serves the current code.
- Declare compatibility with WordPress 7.1.
- Raise minimum WordPress version to 3.1 (required by current APIs).
- Match the text domain to the plugin slug for translations.
- Keep default empty-state HTML out of the translatable string.
- Accept additional
orderbyvalues (rand,type,author) and thepublishedalias. - Accept
onas a truthydisplayimagevalue. - Query child page IDs so the shortcode does not take over the main Loop. Default markup is unchanged.
1.4.1
- Updated keywords for plugin
1.4.0
- Added
parentattribute to target a specific parent page by ID or slug. - Added
sizeattribute to choose featured image size. - Hardened shortcode sanitization and escaping for security.
- Backward-compatible with previous versions.
1.3.2
- Tested in latest versions of WordPress
1.3.1
- Tested in latest versions of WordPress
1.3.0
- Added an option to display the featured image for the page.
- Added class outputs for the ul and li tags in addition to the anchor text.
1.2.2
- Corrected an undeclared variable error.
1.2.1
- Added documentation on where you can see all of the order and orderby parameters.
1.2.0
- Added another shortcode option for the order. Default is DESC.
1.1.0
- Added another shortcode option for the orderby. Default is publish_date.
1.0.0
- Initial Release
Follow this listing's changes (Atom feed)