acf_field_relationship::get_post_title()publicACF 5.0.0

get_post_title

This function returns the HTML for a result

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

Возвращает

(Строку).

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

$acf_field_relationship = new acf_field_relationship();
$acf_field_relationship->get_post_title( $post, $field, $post_id, $is_search );
$post (обязательный)
-
$field (обязательный)
-
$post_id **
-
$is_search **
-

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

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

Код acf_field_relationship::get_post_title() ACF 6.0.4

function get_post_title( $post, $field, $post_id = 0, $is_search = 0 ) {

	// get post_id
	if ( ! $post_id ) {
		$post_id = acf_get_form_data( 'post_id' );
	}

	// vars
	$title = acf_get_post_title( $post, $is_search );

	// featured_image
	if ( acf_in_array( 'featured_image', $field['elements'] ) ) {

		// vars
		$class     = 'thumbnail';
		$thumbnail = acf_get_post_thumbnail( $post->ID, array( 17, 17 ) );

		// icon
		if ( $thumbnail['type'] == 'icon' ) {

			$class .= ' -' . $thumbnail['type'];

		}

		// append
		$title = '<div class="' . $class . '">' . $thumbnail['html'] . '</div>' . $title;

	}

	// filters
	$title = apply_filters( 'acf/fields/relationship/result', $title, $post, $field, $post_id );
	$title = apply_filters( 'acf/fields/relationship/result/name=' . $field['_name'], $title, $post, $field, $post_id );
	$title = apply_filters( 'acf/fields/relationship/result/key=' . $field['key'], $title, $post, $field, $post_id );

	// return
	return $title;

}