get_sub_field

Get_sub_field().

Description

get_sub_field( (string) $field_name ); 

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

Parameters (1)

0. $field_name (string)
The field name.

Usage

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

Defined (1)

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

/core/api.php  
  1. function get_sub_field( $field_name ) { 
  2.  
  3. // no field? 
  4. if( empty($GLOBALS['acf_field']) ) 
  5. return false; 
  6.  
  7.  
  8. // vars 
  9. $row = end( $GLOBALS['acf_field'] ); 
  10.  
  11.  
  12. // return value 
  13. if( isset($row['value'][ $row['i'] ][ $field_name ]) ) 
  14. return $row['value'][ $row['i'] ][ $field_name ]; 
  15.  
  16.  
  17. // return false 
  18. return false;