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.
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.