How to Use the List Pages Template Tag in WordPress - dummies

How to Use the List Pages Template Tag in WordPress

By Lisa Sabin-Wilson

The <?php wp_list_pages(); ?> tag displays a list of the static pages you can create on your WordPress site (such as About Me or Contact pages). Displaying a link to the static pages makes them available so that readers can click the links and read the content you’ve provided.

WordPress has a very handy navigation menu–building tool. It allows you to build different custom navigation menus. If you like the navigation tool, you may never need to use the wp_list_pages(); template tag. You may want to use it if you want to have complete control over how the list of pages appears on your website.

The <list> tag parameters use the string style.

An alternative to using the wp_list_pages() template tag to create a navigation system is to use the built-in feature in WordPress called Menus, which enables you to build custom menus that aren’t completely dependent upon your WordPress pages but that can include links to posts, categories, and custom links that you define.

Parameter Type Description and Values
child_of integer Displays only the subpages of the page; uses the numeric ID for
a page as the value. Defaults to 0
(display all pages).
sort_column string Sorts pages with one of the following options:
‘post_title’ — Sorts alphabetically
by page title (default).
‘menu_order’ — Sorts by page order
(the order in which they appear in the Manage tab and Pages subtab
on the Dashboard).
‘post_date’ — Sorts by the date on
which pages were created.
‘post_modified’ — Sorts by the time
when the page was last modified.
‘post_author’ — Sorts by author,
according to the author ID #.
‘post_name’ — Sorts alphabetically
by the post slug.
‘ID’ — Sorts by numeric Page
Exclude string Lists the numeric page ID numbers, separated by commas, that
you want to exclude from the page list display (for example, ‘exclude=10, 20, 30’). There is no default
Depth integer Uses a numeric value for how many levels of pages are displayed
in the list of pages. Possible options:
0 — Displays all pages, including
main and subpages (default).
1 — Shows subpages but
doesn’t indent them in the list display.
1 — Shows only main pages (no
2, 3 … Displays Pages to the given
show_date string Displays the date when the page was created or last modified.
Possible options:
‘ ‘ — Displays no date
‘modified’ — Displays the date when
the page was last modified.
‘created’ — Displays the date when
the page was created.
date_format string Sets the format of the date to be displayed. Defaults to the
date format configured in the Options tab and General subtab on the
title_li string Types text for the heading of the page list. Defaults to
display the text: “Pages”. If value is
empty (), no heading is displayed; for
example, ‘title_li=My Pages”
displays the heading My Pages above the
page list.

Page lists are displayed in an unordered list (you may know it by the term bulleted list). Whichever term you use, it’s a list with a bullet point in front of every page link.

The following tag and query string displays a list of pages without the text heading “Pages”. In other words, it displays no title at the top of the page’s link list:

<?php wp_list_pages('title_li='); ?>

The next tag and query string displays the list of pages sorted by the date when they were created; the date is also displayed along with the page name:

<?php wp_list_pages('sort_column=post_date&show_date='created'); ?>

Take a look at the way query-string parameters are written:


The entire string is surrounded by single quotation marks, and no white space is within the query string. Each parameter is joined to its value by the = character. When you use multiple parameters/values, you separate them with the & character. You can think of the string like this: parameter1=valueANDparameter2=valueANDparameter3=value.