acf/render_field

Overview

This action is called to render a field input. When creating a custom field type, this action runs the render_field function within the field type class. You can use this action to render HTML before or after the field type’s input.

Changelog

  • Since version 5.0.0
  • Prior to version 5.0.0, this action was known as create_field

Usage

This action is called twice; once in a global sense (for all field types) and once for the specific field type. This action is passed 1 parameter:

  • $field: (array) the field settings including name, label, etc

Global

Each time a field input is rendered, the filter acf/render_field is called.

function action_function_name( $field ) {

	echo '<p>Some extra HTML</p>';

}
add_action( 'acf/render_field', 'action_function_name', 10, 1 );

Specific

Each time a field input is rendered, the filter acf/render_field/type=$field_type is called.

function action_function_name( $field ) {

	echo '<p>Some extra HTML for the image field</p>';

}
add_action( 'acf/render_field/type=image', 'action_function_name', 10, 1 );

action_function_name should be unique function name. It cannot match any other function name already declared.

Notes

  • To render HTML before ACF does, use a priority less than 10
  • To render HTML after ACF does, use a priority of 10 or higher

Related

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.