Home › Forums › Front-end Issues › Count single repeater field › Reply To: Count single repeater field
the_sub_field()
outputs the value, it does not return anything.
Whether or not get_sub_field()
causes an error it is still the function that you must use because you want to get the value and not display the value.
get_sub_field()
may return NULL
or an empty value if the repeater has no rows. So you must get the field first and test it to see if it’s empty before performing any operation on the value
$count = 0;
$repeater_value = get_sub_field('footer_coloumn_spalten')) {
if (!empty($repeater_value)) {
$count = count($repeater_value);
}
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.