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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.