advanced-custom-fields get_field()

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • get_field($field_name, $post_id, $format_value);

Parameters

ParameterDetails
$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_valueDetermine if you want to format the value loaded from the database. Defaults to true. Not required.

Remarks

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.



Got any advanced-custom-fields Question?