Advertisements

get_page_children

Definition:
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.

Parameters

  • 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;

}

1534

Advertisements

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:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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: