Support

Account

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:{}',
      ),  
    );