Documentation

Getting Started

Advanced Custom Fields is a WordPress plugin which allows you to add extra content fields to your WordPress edit screens. These extra content fields are more commonly referred to as Custom Fields and can allow you to build website’s faster and educate your client’s quicker.

Functions

ACF boasts a simple to use and powerful API. Checkout the available functions to power your website.

Basic
get_field()
get_field($selector, [$post_id], [$format_value]);
Returns the value of a specific field.
the_field()
the_field($selector, [$post_id], [$format_value]);
Displays the value of a specific field.
get_field_object()
get_field_object($selector, [$post_id], [$format_value], [$load_value]);
Returns the settings (array) of a specific field
get_fields()
get_fields([$post_id]);
Returns an array of values (name => value) for a specific post
get_field_objects()
$fields = get_field_objects([$post_id]);
Returns an array of field settings (name => field) for a specific post
Loop
have_rows()
have_rows($field_name, [$post_id]);
This function is used to loop over a repeater or flexible content field's value
get_sub_field()
get_sub_field($sub_field_name, [$format_value]);
Returns the value of a specific sub field.
the_sub_field()
the_sub_field($sub_field_name, [$format_value]);
Displays the value of a specific sub field.
get_sub_field_object()
get_sub_field_object($sub_field_name, [$format_value]);
Returns an array of field data (field object + value) for a specific sub field.
get_row()
get_row( [$format_values] );
Return an array containing all sub field values for the current row.
get_row_index()
get_row_index();
Returns the current row index within a have_rows() loop
get_row_layout()
get_row_layout();
Returns the current row layout name within a have_rows() loop
Update
delete_sub_field()
update_field()
update_field($selector, $value, [$post_id]);
Updates a field value.
delete_field()
delete_field($selector, [$post_id]);
Deletes a field value.
update_sub_field()
update_sub_field( $selector, $value, [$post_id] );
Updates a sub field value.
add_row()
add_row( $selector, $value, [$post_id] );
Adds a new row of data to an existing repeater / flexible content field value.
update_row()
update_row( $selector, $row, $value, [$post_id] );
Updates a row of data for an existing repeater / flexible content field value.
delete_row()
delete_row( $selector, $row, [$post_id] );
Deletes a row of data from an existing repeater / flexible content field value.
add_sub_row()
add_sub_row( $selector, $row, [$post_id] );
Adds a row of data for an existing repeater / flexible content sub field value.
update_sub_row()
update_sub_row( $selector, $i, $row, [$post_id] );
Updates a row of data for an existing repeater / flexible content sub field value.
delete_sub_row()
delete_sub_row( $selector, $i, [$post_id] );
Deletes a row of data from an existing repeater / flexible content sub field value.
Other
acf_add_options_page()
acf_add_options_page( $args );
Add a global options page to the WP dashboard
acf_add_options_sub_page()
acf_add_options_sub_page($page);
Add a global options sub page to the WP dashboard
acf_form_head()
acf_form_head();
Validates and saves data submitted from an acf_form().
acf_form()
acf_form( $options );
Creates a front end form.
acf_register_form()
acf_register_form( $settings );
Registers a front end form.
Shortcode
[acf field="field_name"]
Used within a content editor to display a custom field’s value
Deprecated
acf_set_options_page_capability()
acf_set_options_page_menu()
acf_set_options_page_title()
has_sub_field()
the_flexible_field()
the_repeater_field()

Actions

Hook into these actions to customize your ACF experience.

acf/field_group/admin_enqueue_scripts Called during the enqueue_scripts action when editing a field group.
acf/field_group/admin_head Called during the admin_head action when editing a field group
acf/init Called after ACF is finished loading and is similar to the WordPress init action.
acf/input/admin_enqueue_scripts Called during the enqueue_scripts action when editing a post.
acf/input/admin_footer Called during the admin_footer action when editing a post.
acf/input/admin_head Called during the admin_head action when editing a post.
acf/input/form_data Called during the form element when editing a post.
acf/render_field Called when rendering a field input
acf/save_post Called when saving $_POST data
acf/validate_save_post Called when validating $_POST data.
Deprecated
acf_head-fields
acf_head-input
acf_print_scripts-input
acf_print_styles-input
acf_save_post

Filters

Hook into these actions to customize your ACF experience.

acf/compatibility Enable specific backwards compatibility logic
acf/fields/flexible_content/layout_title Customize the text (HTML) displayed at the top of each flexible content layout
acf/fields/google_map/api Customize the URL parameters used to load Google Maps JS
acf/fields/post_object/query Customize the $args array used to query posts for the post object field
acf/fields/post_object/result Customize the result (text) displayed for each option in the post object field
acf/fields/relationship/query Customize the $args array used to query posts for the relationship field
acf/fields/relationship/result Customize the result (text) displayed for each option in the relationship field
acf/fields/taxonomy/query Customize the $args array used to query terms for the taxonomy field (select display)
acf/fields/taxonomy/result Customize the result (text) displayed for each option in the taxonomy field
acf/fields/taxonomy/wp_list_categories Customize the $args array used to query and list terms for the taxonomy field (checkbox and radio display)
acf/format_value Customize the value when it is called from a template function such as get_field()
acf/load_field Customize the field when it is loaded
acf/load_value Customize the value when it is loaded
acf/pre_save_post Customize the $post_id used to save data during the acf_form_head() function
acf/prepare_field Customize the field after its value is loaded (before field is rendered for input)
acf/settings Customize ACF settings which are used throughout the plugin
acf/update_value Customize the value before it is saved
acf/upload_prefilter Perform custom validation on an attachment before it is uploaded
acf/validate_attachment Perform custom validation on an attachment before it is uploaded or selected
acf/validate_value Perform custom validation on a field's value before it is saved
Deprecated
acf_load_field
acf_load_value
acf_update_value
acf/options_page/settings

Frequently Asked Questions

We curated an extensive list of frequently asked questions to help you quickly get on with your project.

If you have a question regarding the ACF plugin or the ACF website, please take a look at the FAQ categories here.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.