function &get_page_children($page_id, $pages) {}

Retrieve child pages from list of pages matching page ID.
Matches against the pages parameter against the page ID. Also matches all children for the same to retrieve all children of a page. Does not make any SQL queries to get the children.


  • int $page_id: Page ID.
  • array $pages: List of pages’ objects.

Source code

function &get_page_children($page_id, $pages) {

	$page_list = array();

	foreach ( (array) $pages as $page ) {

		if ( $page->post_parent == $page_id ) {

			$page_list[] = $page;

			if ( $children = get_page_children($page->ID, $pages) )

				$page_list = array_merge($page_list, $children);



	return $page_list;



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: