Here is what our second-tier supporter found about the warning message you are getting.
Warning: foreach() argument must be of type array|object, string given in ...
It occurs because the get_field() function from ACF can return different types of values depending on how the field is configured — not just arrays. In your case, the 'brands' field appears to be returning a string, but your template is trying to loop over it using foreach(), which only works with arrays or objects.
To prevent this warning and ensure the code only attempts to loop when appropriate, you can update your condition like this:
<?php if (!empty($brands) && is_array($brands)) : $counter = 0; ?>
This adds a safeguard to make sure $brands is actually an array before entering the loop. It should resolve the warning you're seeing.
If you also need to handle cases where brands returns a string (e.g., to display it as a label or fallback), you'll want to add additional logic — but that goes beyond the scope of what we typically assist with.
Please let us know if this information is helpful to you.
Regards,
Itamar.
The topic ‘[Closed] Repeater field is not appear on the translated page’ is closed to new replies.