ACF_Field_Group::filter_posts
Filter the posts returned by $this->get_posts().
Method of the class: ACF_Field_Group{}
No Hooks.
Returns
Array.
Usage
$ACF_Field_Group = new ACF_Field_Group(); $ACF_Field_Group->filter_posts( $posts, $args );
- $posts(array) (required)
- An array of posts to filter.
- $args(array)
- An array of args to filter by.
Default:array()
Changelog
| Since 6.1 | Introduced. |
ACF_Field_Group::filter_posts() ACF Field Group::filter posts code ACF 6.8.8
public function filter_posts( $posts, $args = array() ) {
// Loop over field groups and check visibility.
$filtered = array();
if ( $posts ) {
foreach ( $posts as $post ) {
if ( acf_get_field_group_visibility( $post, $args ) ) {
$filtered[] = $post;
}
}
}
return $filtered;
}