Use the [list-pages]
, [sibling-pages]
, and [child-pages]
shortcodes to display a list of pages.
In this guide
There is less of a need for shortcodes in the modern WordPress experience. To display pages on your site, consider the Blog Posts or Query Loop blocks, which both support pages.
The available shortcodes are:
- The
[list-pages]
shortcode will display all of your pages. - The
[sibling-pages]
shortcode will display all the sibling pages of your current page. Sibling pages are pages that share the same parent page. - The
[child-pages]
shortcode will display all the child pages of your current page. Child pages are pages that are under a parent page.
If you have a plugin-enabled site, you must install the Display Posts Shortcode plugin to ensure the shortcodes work.
The list-pages shortcodes are highly customizable. Below is a listing of all the available customization options.
sort_column
: sorts the list of pages in a number of different ways. The default setting is to sort alphabetically by page title.post_title
– Sort pages alphabetically by title (Default).menu_order
– Sort pages by page order. Note the difference between page order and page ID. The page ID is a unique number assigned by WordPress to every post or page. The page order can be set by the user when editing the page.post_date
– Sort by creation time.post_modified
– Sort by the time the page was last modified.ID
– Sort by numeric page ID.post_author
– Sort by the page author’s numeric ID.- post_name – Sort alphabetically by post slug.
sort_order
: change the sort order of the list of pages (either ascending or descending). The default is ascending.
ASC
– Sort from lowest to highest (default).DESC
– Sort from highest to lowest.
exclude
: define a comma-separated list of page IDs to be excluded. There is no default value.
(Example: 'exclude=3,7,31'
)
exclude_tree
: define a comma-separated list of parent page IDs to be excluded. Use this parameter to exclude a parent and all of that parent’s child pages.
(Example: 'exclude_tree=5'
would exclude the parent page with the page ID of 5, and its child pages)
include
: only include certain pages. Like exclude, this parameter takes a comma-separated list of page IDs. There is no default value.
depth
: this parameter controls how many levels in the hierarchy of pages are to be included. The default is 0 (display all pages, including all sub-pages).
0
– Displays pages at any depth and arranges them hierarchically in nested lists (default).-1
– Displays pages at any depth and arranges them in a single, flat list.1
– Displays top-level pages only.2, 3 …
– Displays pages to the given depth.
child_of
: displays the sub-pages of a single page only; uses the ID for a page as the value. Note that the child_of parameter will also fetch “grandchildren” of the given ID, not just direct descendants. The default is 0 (displays all pages).
show_date
: display creation or last modified date next to each page. The default is the null value (do not display dates).
''
– Display no date (default).- modified – Display the date last modified.
- xxx – Any value other than modified displays the date (post_date) the page was first created.
date_format: controls the format of the page date set by the show_date parameter. This parameter defaults to the date format configured in your WordPress options in Settings → General. (Example: ‘l, F j, Y’)
For more information on formatting your date please see the date format page on the PHP website.
title_li
: set the text and style of the page list’s heading. If passed a null or empty value (”), no heading is displayed, and the list will not be wrapped with <ul>, </ul> tags. Defaults to (”).
link_before
: sets the text or html that precedes the link text inside <a> tag.
link_after
: sets the text or html that follows the link text inside <a> tag.
authors
: only include pages authored by the authors in this comma-separated list of author IDs. If no authors are specified, all authors are included.
offset
: the number of pages to skip before collecting the set of pages. The default is no offset.
post_status
: a comma-separated list of all post status types to return. (Example: 'publish,private'
)
When using one of the above customization options, your shortcode should look something like this: [shortcode option='setting']
Example:
[list-pages sort_column='post_date']
(This will show all pages sorted by post date)