List Subpages
What is it?
On my site, I use the WordPress Page hierarchy as a way of categorising all of my static posts. All the pages about my WordPress plugins, for example, are children of the /projects/plugins/wordpress page; all my articles are children of the /articles page.
What this system lacked, I thought, was the ability to list a parent Page’s subpages in a similar way to how category archives work – on my site, for example, the /projects/plugins/wordpress page will probably never have any proper content; it simply serves as a category, the parent of all the pages detailing my WordPress plugins.
So, I wrote this plugin to allow that. It adds two easy ways of displaying child Pages on a parent Page.
Download
Download List Subpages (Version 2.1)
List Subpages has been downloaded 10,351 times.
Installation
Simply upload the PHP file to your plugins directory and activate it.
Usage
Once you’ve got the plugin installed, you’ll want to be using it.
List Subpages works in two ways; you can either add a template to your Pages that displays the list right there, or you can create a Page Template1
Post Tag
This is probably the easiest method of displaying the hierarchy, but is slightly less flexible. For most people, however, it is perfectly adequate.
To use this method:
- Edit the page you’d like to display the hierarchy on.
At the point at which you’d like to display the hierarchy, insert the following tag:
<subpages />- You’re done!
Page Template
This method is a little more involved, but will allow you more flexibility and control over the display of the page hierarchy.
To use this method:
- Copy your theme’s
page.phpto a new file in your theme directory, calledlist-subpages.php. - Edit it and find the place where you’d like to display the hierarchy.
Paste the following code:
list_subpages();- The function will generate the ouput – just as it does with the template tag – within an HTML
divwith aclassoflist_subpages, allowing you to control how the output appears using CSS. - Edit the pages on which you’d like to display the hierarchy, and from the “Page Template” section on the right, choose the “List Subpages” template you just created.
- You’re done!
For Kubrick users – it’s the default WordPress theme – I’ve created a ready-made page template that you can drop into your wp-content/themes/default/ directory.
Save this file as list-subpages.php, upload it to that directory, and you’re done.