acf_field_post_object::render_fieldpublicACF 3.6

Create the HTML interface for the post object field.

Метод класса: acf_field_post_object{}

Хуков нет.

Возвращает

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

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

$acf_field_post_object = new acf_field_post_object();
$acf_field_post_object->render_field( $field );
$field(массив) (обязательный)
An array holding all the field's data.

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

С версии 3.6 Введена.

Код acf_field_post_object::render_field() ACF 6.4.2

public function render_field( $field ) {
	// Change Field into a select
	$field['type']    = 'select';
	$field['ui']      = 1;
	$field['ajax']    = 1;
	$field['nonce']   = wp_create_nonce( 'acf_field_' . $this->name . '_' . $field['key'] );
	$field['choices'] = array();

	// load posts
	$posts = $this->get_posts( $field['value'], $field );

	if ( $posts ) {
		foreach ( array_keys( $posts ) as $i ) {

			// vars
			$post = acf_extract_var( $posts, $i );

			// append to choices
			$field['choices'][ $post->ID ] = $this->get_post_title( $post, $field );
		}
	}

	// render
	acf_render_field( $field );
}