Support

Account

Home Forums General Issues hide item from post_object field Reply To: hide item from post_object field

  • There isn’t any easy way to do this and there isn’t any simple code I can post. There would be a lot of coding and testing involved to do something like this. All I can do is explain how it can be done.

    If I needed to do this I would use an option https://codex.wordpress.org/Options_API.

    I would create an acf/save_post action that runs before acf (priority < 10). I would look at the value of the relationship field, both the old value and the new value and update my option value as needed.

    I would then create an acf/fields/relationship/query filter https://www.advancedcustomfields.com/resources/acf-fields-relationship-query/ that used the stored option value to prevent these posts from being selected.

    It gets even more complicated because you need to not prevent the selection of the related post that is already selected for the current post being edited if there is already a post selected.