jamie holliday
jamie holliday

Reputation: 1627

Wordpress list pages with children

Hi guys this looks doable but I cant quite figure it out. I have a lists of pages in wordpress

Page1
Page2
Page3
Page4

when you are on a page need to display it's children but only it's children and not the children of the other pages (which all have children)

Page1
Page2
    -child1
    -child2
    -child3
        --grandchild1
        --grandchild2
    -child4
Page3
Page4

I have checked the codex but I don't think it does this? Can anyone help?

Thanks Jamie

Upvotes: 2

Views: 1035

Answers (2)

kevtrout
kevtrout

Reputation: 4984

You can also use wp_list_pages('childof=$parentPageID');

Upvotes: 1

Pat
Pat

Reputation: 25675

Sure, you can do this with get_page_children(). It takes a parent page ID and an array of all pages and returns a filtered array that only contains the pages that are children of the parent page.

Upvotes: 0

Related Questions