Home › Forums › ACF PRO › Relationship Field: How to exclude posts that have already been related? › Reply To: Relationship Field: How to exclude posts that have already been related?
For anyone who may find this in the future, I was able to achieve this by use the ACF Post-2-Post plugin, as well as the acf/fields/relationship/query
filter.
Inside the filter, I only populate the results with ‘Lessons’ that have either no value (”) or have had a value set, but no longer do (‘a:0:{}’). (That’s ACF’s markup.)
$args['meta_query'] = array (
'relation' => 'OR',
array (
'key' => 'lessons',
'value' => '',
'compare' => '=',
),
array (
'key' => 'lessons',
'value' => 'a:0:{}',
),
);
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.