How to get a formatted array of all child pages of a parent page
-
Hello!
I’m running a WordPress based site and most of it’s pages have a navigation menu on the left side. I use it to list the all subpages within a parent page.
Here’s one example: Tapps
I currently manage that listing manually using the following code:
<?php if ( is_page(array('parent', 'child1', 'child2', 'child3'))) { wp_list_pages( 'child_of=1&link_before=<span class="submenu-nav-item">&link_after=</span>&title_li=' ); } else { echo "error"; } ?>
The
is_page
lists the parent page and it’s childs, so whenever I’m on the parent page or one of it’s childs, I have that menu on the left side.The problem is that every time I create a new child page, I have to add a new item in the array.
Is there an easy way to make WP list my parent page and it’s childs so I do not have to do it manually every time?
I think it’s silly question, but I couldn’t figure it out yet.
Thanks in advance!
- The topic ‘How to get a formatted array of all child pages of a parent page’ is closed to new replies.