wc_get_page_children()WC 1.0

Recursively get page children.

Хуков нет.

Возвращает

int[].

Использование

wc_get_page_children( $page_id );
$page_id(int) (обязательный)
Page ID.

Код wc_get_page_children() WC 8.7.0

function wc_get_page_children( $page_id ) {
	$page_ids = get_posts(
		array(
			'post_parent' => $page_id,
			'post_type'   => 'page',
			'numberposts' => -1, // @codingStandardsIgnoreLine
			'post_status' => 'any',
			'fields'      => 'ids',
		)
	);

	if ( ! empty( $page_ids ) ) {
		foreach ( $page_ids as $page_id ) {
			$page_ids = array_merge( $page_ids, wc_get_page_children( $page_id ) );
		}
	}

	return $page_ids;
}