the_field

The_field().

Description

the_field( (string) $field_name, (bool) $post_id = false ); 

This function is the same as echo get_field().

Parameters (2)

0. $field_name (string)
The field name.
1. $post_id — Optional. (bool) => false
The post id.

Usage

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

Defined (1)

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

/core/api.php  
  1. function the_field( $field_name, $post_id = false ) { 
  2.  
  3. $value = get_field($field_name, $post_id); 
  4.  
  5. if( is_array($value) ) 
  6. $value = @implode(', ', $value); 
  7.  
  8. echo $value;