Documentation

the_field()

Description

Displays the value of the specified field. (this is the same as “echo get_field($field_name)”)

Parameters

<?php the_field($field_name, $post_id); ?>
  • $field_name: the name of the field to be retrieved. eg “page_content” (required)
  • $post_id: Specific post ID where your value was entered. Defaults to current post ID (not required). This can also be options / taxonomies / users / etc

Usage

<?php 

/*
*  display a field value from the current post
*/

the_field( "text_field" ); 

/*
*  display a field value from another post
*/

the_field( "text_field", 123 ); 

/*
*  use the_field / get_field with conditional statements
*/

if( get_field( "text_field" ) ): ?>
    <p><?php the_field( "text_field" ); ?></p>
<?php endif;