acf_render_fields()ACF 5.0.0

acf_render_fields

Renders an array of fields. Also loads the field's value.

Возвращает

null. Ничего (null).

Использование

acf_render_fields( $fields, $post_id, $el, $instruction );
$fields(массив) (обязательный)
An array of fields.
$post_id((int|string))
The post ID to load values from.
$el **
-
По умолчанию: 'div'
$instruction(строка)
The instruction render position (label|field).
По умолчанию: 'label'

Список изменений

С версии 5.0.0 Введена.
С версии 5.6.9 Changed parameter order.

Код acf_render_fields() ACF 6.0.4

function acf_render_fields( $fields, $post_id = 0, $el = 'div', $instruction = 'label' ) {

	// Parameter order changed in ACF 5.6.9.
	if ( is_array( $post_id ) ) {
		$args    = func_get_args();
		$fields  = $args[1];
		$post_id = $args[0];
	}

	/**
	 * Filters the $fields array before they are rendered.
	 *
	 * @date    12/02/2014
	 * @since   5.0.0
	 *
	 * @param   array $fields An array of fields.
	 * @param   (int|string) $post_id The post ID to load values from.
	 */
	$fields = apply_filters( 'acf/pre_render_fields', $fields, $post_id );

	// Filter our false results.
	$fields = array_filter( $fields );

	// Loop over and render fields.
	if ( $fields ) {
		foreach ( $fields as $field ) {

			$field = apply_filters( 'acf/pre_render_field', $field, $post_id );

			// Load value if not already loaded.
			if ( $field['value'] === null ) {
				$field['value'] = acf_get_value( $post_id, $field );
			}

			// Render wrap.
			acf_render_field_wrap( $field, $el, $instruction );
		}
	}

	/**
	*  Fires after fields have been rendered.
	*
	*  @date    12/02/2014
	*  @since   5.0.0
	*
	* @param    array $fields An array of fields.
	* @param    (int|string) $post_id The post ID to load values from.
	*/
	do_action( 'acf/render_fields', $fields, $post_id );
}