Support

Account

Home Forums ACF PRO Max items for post object field Reply To: Max items for post object field

  • You could use a relationship field instead. A post object field that allows multiple values is just another way of displaying a relationship field.

    Or you can create an acf/validate_value filter https://www.advancedcustomfields.com/resources/acf-validate_value/. $value in this case will be an array of post IDs and you can do

    if (count($value) > $my_max_posts) {
      $valid = 'No more than '.$my_max_posts.' allowed';
    }
    

    I’d also add a note to the field instructions about the maximum.

    You could probably also do this using javascript and the select2_init hook to alter the select2 settings https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/