get_field($field_name, $post_id, $format_value);
Parameter | Details |
---|---|
$field_name | (string) The name of the field you are requesting. When setting up your field group, this is the "Field Name" setting. |
$post_id | (integer) This is the ID of the post that you are requesting the field name from. This can also be 'options' or a taxonomy reference. This can be left blank when inside of the WordPress loop, if requesting the current post/page ID. |
$format_value | Determine if you want to format the value loaded from the database. Defaults to true. Not required. |
get_field() vs. the_field()
the_field() automatically displays the field value on your page, where get_field() does not. Use get_field() when assigning field values to variables, or when manipulating the returned content in your code.