get_sub_field_object

Get_sub_field_object().

Description

get_sub_field_object( (string) $child_name ); 

This function is used inside a has_sub_field while loop to return a sub field object

Parameters (1)

0. $child_name (string)
The child name.

Usage

  1. if ( !function_exists( 'get_sub_field_object' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'advanced-custom-fields/core/api.php'; 
  3.  
  4. // The child name. 
  5. $child_name = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_sub_field_object($child_name); 
  9.  

Defined (1)

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

/core/api.php  
  1. function get_sub_field_object( $child_name ) 
  2. // no field? 
  3. if( empty($GLOBALS['acf_field']) ) 
  4. return false; 
  5.  
  6.  
  7. // vars 
  8. $depth = count( $GLOBALS['acf_field'] ) - 1; 
  9. $parent = $GLOBALS['acf_field'][$depth]['field']; 
  10.  
  11.  
  12. // return 
  13. return acf_get_child_field_from_parent_field( $child_name, $parent ); 
  14.