WordPress: Site Map

Creating a site map with WordPress is very simple. You might find it very handy especially if you’re running your whole site on WordPress, because this site map is automatic.

Firstly, you will need to have Exec PHP or PHP Execution installed and activated so you can use PHP within your pages.

Create a new page with whatever title you like.

Using the HTML editor, paste the following code:

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

This will display a site map of all the pages on your website in a bulleted list. By default, all published pages are displayed with no limit to depth and basically, no restrictions. They are also displayed in a hierarchical fashion in alphabetical order by page title.

It’s as simple as that. However, if you’re looking into customising, read ahead.


There are many parameters which can be seen at the Codex but I have chosen to only display commonly used ones and how to use them.


If you’re not liking the default alphabetical order, you can change your code by adding the parameter in bold:

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

By using the ampersand (&), you are adding another parameter along with the current one title_li.

sort_column has several variables. You can place these after the equals sign to have them take effect:

For example, this would be your code if you wanted to sort by the post date:

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


If you aren’t liking the order of the pages and would like to reverse them, use the following code:

<?php wp_list_pages('title_li=&sort_order=desc'); ?>

Because, by default, the list is ascending. Don’t forget that if you have chosen to change other parameters, you add them along with others using &:

<?php wp_list_pages('title_li=&sort_column=post_modified&sort_order=desc'); ?>


Hopefully from reading a bit of the above you’re familiar with how to put the variables together.

exclude allows pages of specified IDs to be excluded from the list. For example, exclude=3,4,56 would exclude pages with the IDs 3, 4, and 56.


This is similar to exclude. Simply type in the page IDs of the pages you would like to be included.

For example, include=3,4,56 would include ONLY pages with the IDs 3, 4, and 56.


This parameter controls the levels in the list of pages generated. By default, pages are displayed so that child pages (pages under a parent page) are indented using a nested list. However, this can be changed with the depth parameter and the following variables:


This only displays the child pages of a parent page, for instance, the written book reviews listed under a main “book reviews” page. Use as child_of=5, where the number 5 represents the page ID of the parent page.


This shows the date of the page (next to its name) when it was created or modified. By default no dates are displayed.


By default, if you choose to use show_date above, the date will display the way you have specified in your WordPress options – under Settings, General. This parameter allows you to change it using variables at php.net/date, for example:

<?php wp_list_pages('title_li=&show_date=modified&date_format=l, F j, Y'); ?>