Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
10:00 – 14:00 10:00 – 14:00 10:00 – 14:00 10:00 – 14:00 10:00 – 14:00 - -
16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 - -

Supporter timezone: Asia/Jerusalem (GMT+03:00)

This topic contains 12 replies, has 0 voices.

Last updated by Itamar 1 month, 2 weeks ago.

Assisted by: Itamar.

Author Posts
May 14, 2025 at 4:04 pm #17033719

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

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.