_page_traverse_name

Traverse and return all the nested children post names of a root page.

Description

_page_traverse_name( (int) $page_id, (array) &$children, (array) &$result ); 

$children contains parent-children relations

Parameters (3)

0. $page_id (int)
The page id.
1. $children (array) => &$children
Parent-children relations, passed by reference.
2. $result (array) => &$result
Result, passed by reference.

Usage

  1. if ( !function_exists( '_page_traverse_name' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3.  
  4. // The page id. 
  5. $page_id = -1; 
  6.  
  7. // Parent-children relations, passed by reference. 
  8. $children = array(); 
  9.  
  10. // Result, passed by reference. 
  11. $result = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = _page_traverse_name($page_id, $children, $result); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post.php  
  1. function _page_traverse_name( $page_id, &$children, &$result ) { 
  2. if ( isset( $children[ $page_id ] ) ) { 
  3. foreach ( (array)$children[ $page_id ] as $child ) { 
  4. $result[ $child->ID ] = $child->post_name; 
  5. _page_traverse_name( $child->ID, $children, $result );