Support

Account

Home Forums Front-end Issues get_sub_field function return false for all Reply To: get_sub_field function return false for all

  • You have a repeater nested within an ACF flexible content field so where get_sub_field is looking for data is changing based on where you’re placing it.

    Ex: when you put it ABOVE the slider repeater, it’s looking for the image field in the flexible content area. When you put it after the loop for your repeater, it’s looking for the image field as a subfield of “slider”. That’s why it’s returning null when you move where it’s located.

    If you want to use a field assigned to the flexible content layout inside of the nested repeater, your best bet would be likely to assign it to a variable ahead of opening your slider repeater loop so leave the $image variable where it is in your working example and then reference that variable within your slider repeater loop.