List pages in WordPress

WordPressWordPress as a great capability to handle non-blog posts. You can easily create a page, assign certain pages under parent page, and more. The next question: how to display list of pages easily?
The basic tag to produce list of pages created from your WordPress is like this:

<?php wp_list_pages(''); ?>

Using the simple code above your will have this:

<li class="pagenav">Pages
<ul>
<li class="page_item"><a href="#" title="Page name">Page name</a></li>
<li class="page_item"><a href="#" title="Page name">Page name</a></li>
<ul>
<li class="page_item"><a href="#" title="Sub page name">Sub page naem</a></li>
<li class="page_item"><a href="#" title="Sub page name">Sub page naem</a></li>
</ul>
</li>
<li class="page_item"><a href="#" title="Page name">Page name</a></li>
</ul>
</li>


Here are some other template code you can use to have different outputs:

Without heading

If you want to hide the heading (default heading is: “Pages”), use this code:

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

When creating pages, you have option to display the order. If you want to display list of pages by Page Order, use this:

<ul>
<?php wp_list_pages('sort_column=menu_order'); ?>
</ul>

And, if you want to display your list of pages link based on “Page Order” and having this kind of output:

<ul>
<li><a href="#" title="Page name">Page name</a></li>
<li><a href="#" title="Page name">Page name</a></li>
</ul>

Use this code:

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

Read more information about displaying list of pages in WordPress (and its combinations at WordPress Codex: Template Tags: wp_list_pages.