acf_field_post_object::get_post_titlepublicACF 5.0.0

This function post object's filtered output post title

Method of the class: acf_field_post_object{}

Returns

String. A potentially user filtered post title for the post, which may contain unsafe HTML.

Usage

$acf_field_post_object = new acf_field_post_object();
$acf_field_post_object->get_post_title( $post, $field, $post_id, $is_search, $unescape );
$post(WP_Post) (required)
The WordPress post.
$field(array) (required)
The field being output.
$post_id(int)
The post_id to which this value is saved to.
$is_search(int)
An int-as-boolean value for whether we're performing a search.
$unescape(true|false)
Should we return an unescaped post title.
Default: false

Changelog

Since 5.0.0 Introduced.

acf_field_post_object::get_post_title() code ACF 6.8.8

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

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

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

	// unescape for select2 output which handles the escaping.
	if ( $unescape ) {
		$title = html_entity_decode( $title );
	}

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

	// return untrusted output.
	return $title;
}