Wordpress - List a specific page and sub pages from a page template or make a new menu?

Go To StackoverFlow.com


Hi I have been trying for hours to display a four column grid of specific pages and their children on my page template. My site structure is:

    Main Page
    Service Page
    -Service Type 1
    --Service Type 1, Item 1
    --Service Type 1, Item 2
    -Service Type 2
    --Service Type 2, Item 1
    --Service Type 2, Item 2

I am having difficulty trying to list my "Service Types" and there sub pages from my page template.

I was trying to make an array of page ids (Ids from the "Service Types") and display the titles of these pages.

Then I want to search the array and see if the pages in it have children and if so display the child titles underneath as links (following my css).

It doesn't sound to difficult but I can't seem to get my head around it. I have been mashing code together but cant figure it out.

I can display the pages in a basic list using:

<?php wp_list_pages('include=453&title_li='); ?>
<?php wp_list_pages('child_of=453&sort_column=post_title&title_li=') ?>
<?php wp_list_pages('include=457&title_li='); ?>
<?php wp_list_pages('child_of=457&sort_column=post_title&title_li=') ?>

But would like to have something more dynamic so if I add more service types I dont have to manually enter all the code, instead I could populate the array with a new id?

I want the top grid of my page to have something like:

    -Service Type 1            -Service Type 2            -Service Type 3
    --Service Type 1, Item 1   --Service Type 2, Item 1   --Service Type 3, Item 1
    --Service Type 1, Item 2   --Service Type 2, Item 2   --Service Type 3, Item 1

Am I approaching this right or should I make some sort of menu? Any help with this would be greatly appreciated!


2012-04-03 21:16
by Steve


Turns out instead of listing pages and sub pages it was easier to create a new menu in order to achieve what I was trying to get.

I used the code here to make the second menu:


I had a problem with the 'home' page appearing in the second menu so I used the function found here to remove it:


2012-04-04 09:51
by Steve
don't forget to accept the answer by clicking the checkmark to the left, so if someone needs this in the future, they will know the answer has been posted - Theresa 2012-04-04 20:42