acf_field_post_object::get_postspublicACF 5.0.0

get_posts

This function will return an array of posts for a given field value

Method of the class: acf_field_post_object{}

No Hooks.

Returns

$value.

Usage

$acf_field_post_object = new acf_field_post_object();
$acf_field_post_object->get_posts( $value, $field );
$value(required)
.
$field(required)
.

Changelog

Since 5.0.0 Introduced.

acf_field_post_object::get_posts() code ACF 6.0.4

function get_posts( $value, $field ) {

	// numeric
	$value = acf_get_numeric( $value );

	// bail early if no value
	if ( empty( $value ) ) {
		return false;
	}

	// get posts
	$posts = acf_get_posts(
		array(
			'post__in'  => $value,
			'post_type' => $field['post_type'],
		)
	);

	// return
	return $posts;

}