I am using a relationship field, inside a repeater, to pull from a custom post type right now and it works great. Issue is that for my situation I need to limit the selections for each row to just 1. So two questions;
1. Is there a way to limit choices to 1 in relationship fields?
2. If not, could there be a way to have a select list with values populated from custom post type titles?
Hi @thatryan,
Thanks for the question.
Yes this is possible, you will only need to make use of the acf/fields/relationship/query filter and modify the $args array that is used to query the posts in the field.
The code will look like so:
<?php
function my_relationship_query( $args, $field, $post_id ) {
// limit number of posts
$args['posts_per_page'] = 1;
// return
return $args;
}
// filter for every field
add_filter('acf/fields/relationship/query', 'my_relationship_query', 10, 3);
?>