acf_field_post_object::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
array. $value An array of post objects.
Usage
$acf_field_post_object = new acf_field_post_object(); $acf_field_post_object->get_posts( $value, $field );
- $value(mixed) (required)
- The value of the field.
- $field(array) (required)
- The field array holding all the field options.
Changelog
| Since 5.0 | Introduced. |
acf_field_post_object::get_posts() acf field post object::get posts code ACF 6.8.8
public 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;
}