walk_page_tree

Retrieve HTML list content for page list.

Description

(string) walk_page_tree( (array) $pages, (int) $depth, (int) $current_page, (array) $r ); 

Returns (string)

Parameters (4)

0. $pages (array)
The pages.
1. $depth (int)
The depth.
2. $current_page (int)
The current page.
3. $r (array)
The r.

Usage

  1. if ( !function_exists( 'walk_page_tree' ) ) { 
  2. require_once ABSPATH . WPINC . '/post-template.php'; 
  3.  
  4. // The pages. 
  5. $pages = array(); 
  6.  
  7. // The depth. 
  8. $depth = -1; 
  9.  
  10. // The current page. 
  11. $current_page = -1; 
  12.  
  13. // The r. 
  14. $r = array(); 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = walk_page_tree($pages, $depth, $current_page, $r); 
  18.  

Defined (1)

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

/wp-includes/post-template.php  
  1. function walk_page_tree( $pages, $depth, $current_page, $r ) { 
  2. if ( empty($r[walker]) ) 
  3. $walker = new Walker_Page; 
  4. else 
  5. $walker = $r[walker]; 
  6.  
  7. foreach ( (array) $pages as $page ) { 
  8. if ( $page->post_parent ) 
  9. $r['pages_with_children'][ $page->post_parent ] = true; 
  10.  
  11. $args = array($pages, $depth, $r, $current_page); 
  12. return call_user_func_array(array($walker, 'walk'), $args);