Customizing WordPress - Setting up a Hierarchy of Static Pages

This is the second post in a short series about how I modified WordPress to suit my needs.

This post explains how I set up a hierarchy of static pages, and created a navigation system to allow navigation to those pages.

WP allows you to create a hierarchical structure of static pages. On the page editing form, you can choose which page should be that page’s parent. No parent means that page is a top-level page. There is a built-in function, wp_list_pages, that outputs a list of pages.

Here is the function call I use in my header file to display just the top level pages:

wp_list_pages('title_li=&depth=1&exclude=14&sort_column=menu_order');

You should read more about this function in the WP Codex for more information, but the key part in this case is depth=1. The one means to display only the pages at level one in the hierarchy. Using 0, or omitting the argument entirely, causes WP to list ALL the pages. In that case, WP shows the hierarchical structure using nested lists. In this case, WP only shows the top-level pages.

This is easy enough if you only have a few top-level pages, but what if you also want to display child pages for the CURRENT page? Read on…

Pages: 1 2

Comments are closed.