I have 2 post types: Courses and Lessons. I’m using a Relationship field to relate the Lessons to the Courses. What I would like to do is exclude Lessons that have already been related to another course.
Essentially, each Lesson would only be able to be related to ONE course.
I’m using the acf/fields/relationship/query/
filter, but I’m not sure if it’s even possible.
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:{}',
),
);