Home Forums ACF PRO Relationship Field (Post Object) filtering Reply To: Relationship Field (Post Object) filtering

  • @fishnyc22 your problem here is using get_the_ID(). This filter is run during an AJAX request and whatever that function is returning it’s not the ID of the post that’s being edited. ACF passes the post ID in the function call, which I see that you’ve tried to use in the commented out version. Try using that in the attempt that you do not have commented out.

    If this still fails, the post type you’re trying alter the query on a hierarchical post type were a child post can be related to the current post and the parent of that post may not be?

    Another problem could be the way that the field ‘rfi_project’ is stored. What type of field is this? Is it a relationship field or another post object field that can have multiple values? If it is then is is stored as a serialized array and you cannot an ‘==’ meta query and you need to use

    $meta_query[] = array(
      'key' => 'rfi_project',
      'value' => '".$post_id."',
      'compare' => 'LIKE'