I am building a site for a client, and I want to list all the child Pages, which will be many, of one of their parent pages in the sidebar. To help you understand better, this client provides many services, so I wanted there to be a parent Page called “Services,” and this parent Page will have a list of child Pages, each of which goes into detail about each specific service.
I couldn’t find any information on how to do this, but then I came across a tag for categories that allows you to only list the subcategories of a specific category. This tag is as follows:
1 |
<?php wp_list_cats('child_of=8, 14'); ?> |
By using this tag, you would only list the child categories of the categories with IDs of 8 and 14. So I decided to see if this would work with Pages, and it did!
So here’s the code I put in the sidebar to list only the child Pages of the Services Page, sorted alphabetically and omitting the title of “Pages”:
<?php wp_list_pages('child_of=2&sort_column=post_title&title_li=') ?>
Hurray!
Pingback: Happy birthday to WordPress Garage! | Wordpress Garage()