Home › Forums › General Issues › Trouble with acf/fields/post_object/query Filter › Reply To: Trouble with acf/fields/post_object/query Filter
post__not_in
should be an array, so that’s the first suggested change
add_filter( 'acf/fields/post_object/query/name=my_field', [ $this, 'my_filter' ] );
public function my_filter( $args, $field, $post_id ) {
$field; // Undefined
$post_id; // Undefined
if(isset($post_id)) {
$args['post__not_in'] = array([$post_id]);
}
return $args;
}
If this field is a sub field of a repeater or flex field you also need to use the field key for adding the filter.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.