wc_get_page_children

Recursively get page children.

Description

(int[]) wc_get_page_children( (int) $page_id ); 

Returns (int[])

Parameters (1)

0. $page_id (int)
The page id.

Usage

  1. if ( !function_exists( 'wc_get_page_children' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-core-functions.php'; 
  3.  
  4. // The page id. 
  5. $page_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_get_page_children($page_id); 
  9.  

Defined (1)

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

/includes/wc-core-functions.php  
  1. function wc_get_page_children( $page_id ) { 
  2. $page_ids = get_posts( array( 
  3. 'post_parent' => $page_id,  
  4. 'post_type' => 'page',  
  5. 'numberposts' => -1,  
  6. 'post_status' => 'any',  
  7. 'fields' => 'ids',  
  8. ) ); 
  9.  
  10. if ( ! empty( $page_ids ) ) { 
  11. foreach ( $page_ids as $page_id ) { 
  12. $page_ids = array_merge( $page_ids, wc_get_page_children( $page_id ) ); 
  13.  
  14. return $page_ids;