I have a Repeater field of Post Objects (here, a custom post type Participants) and I’d like a Relationship field’s options to be populated based on the Post Objects that were selected. I created a stand-alone function with an SQL query which works perfectly using $wpdb->get_results(), but I can’t figure out how to convert it into the WP_Query required by a Relationship field, or if there’s a way to simply feed the Relationship field the options I need directly.
Here’s the SQL that correctly gets my required data directly:
$results = $wpdb->get_results(
FROM <code>wp_postmeta</code> m
JOIN wp_posts part ON part.ID = m.meta_value
WHERE part.ID = m.meta_value
AND m.meta_key LIKE 'participants_%_participant'
AND m.post_id = '$class_id'
AND post_type = 'participant'
AND post_status = 'publish'
") or die(mysql_error());
And here’s what I have so far using the acf/query filter (It doesn’t work):