wpseek.com
A WordPress-centric search engine for devs and theme authors



nest_pages › WordPress Function

Sincen/a
Deprecatedn/a
nest_pages ( $current_level, $children )
Parameters: (2)
  • (array) $current_level The level being iterated through.
    Required: Yes
  • (array) $children The children grouped by parent post ID.
    Required: Yes
Returns:
  • (array) The nested array of pages.
Defined at:
Codex:

Outputs nested array of pages



Source

function nest_pages( $current_level, $children ) {
	if ( empty( $current_level ) ) {
		return;
	}
	foreach ( (array) $current_level as $key => $current ) {
		if ( isset( $children[ $key ] ) ) {
			$current_level[ $key ]['children'] = nest_pages( $children[ $key ], $children );
		}
	}
	return $current_level;
}