Listing Pages with wp_list_pages

In WordPress pages may be listed using the function wp_list_pages

For example to list the top level WordPress pages

<?php wp_list_pages(‘depth=1’ ); ?>

The function can be used to restrict the pages listed. For example placing the function within the template footer to show only the Privacy Statement, Terms of Use and Cookie Policy.

If these three pages have id references of 22, 23 and 24 then the include attribute can be used to only show these three:

<?php wp_list_pages(‘include=22,23,24’ ); ?>

I have used the function in the past, to omit the usual set of site legal page references:

<?php wp_list_pages(‘exclude=22,23,24’ ); ?>

A fuller example of the functions usage is given below:
<?php wp_list_pages(‘exclude=22,23,24&sort_column=menu_order&title_li=&depth=3’); ?>

In this example the parameters add the following filtering/presentation:

  • exclude – pages are excluded as before
  • depth – only 3 levels parent plus two child levels
  • menu_order – the items are ordered according to the menu and the it
  • title_li – sets the title and style of the outer list item. If the attribute is present, but empty, the outer list item will not be displayed

Available options for the wp_list_pages function include:

Option Description Default
child_of Only select children of the specified page ID 0
optiondates Display the date the page was created 0
date_format Use this date format instead of the one from the options ‘’
depth Only recurse this deep, if set to 0 display all levels 0
sort_column Sort output by this column post_title
sort_order Specify the sort order ASC
depth Defines how deep the menu listing should go. A value of 1 will be the top level only.  
exclude Define the pages which are  to be excluded.