Support

Account

Home Forums General Issues Generate sub field from php – check if content already exists Reply To: Generate sub field from php – check if content already exists

  • The field object contains the field definition used by ACF.

    If you just want to check the number of rows in a repeater the simplest way to do that is to use $count = intval(get_post_mets($post_id, 'repeater_field', true)); The values stored by ACF in the post_meta table for the repeater is the number of rows it contains.

    If you want to check the actual values in those rows then you need to use the ACF while(have_rows()) { the_row; get_sub_field('subfield');} code used for repeater fields.

    There are some cases that get_field('repeater') will actually return an array with the content of sub fields, but that is not something that you can count on. There are other times when it just returns the number of rows as in the get_post_meta() code above.