Support

Account

Home Forums Add-ons Repeater Field get_field() for repeater returning string instead of array Reply To: get_field() for repeater returning string instead of array

  • I’ve had this issue before and this time I figured it out. I found while using get_field, it was returning “11”. I dug into the source code and found the field was returning false for “acf_get_field”. The chain looks like:

    get_field() -> acf_maybe_get_field() -> acf_get_meta_field() -> acf_get_field()

    It was failing because I deleted the field at one point. I added it back in with all the same settings, but the field key changed.

    I didn’t have anything tied to the field key so I thought it was alright.

    But the problem is existing posts saved with an old field key will not load the new field correctly. For example if I create a “subtitle” acf field I might get the key “field_000001”. And if I delete that and create a new “subtitle” field, it is now key “field_000002”.

    And that matters because when your post saves “subtitle = cats” it also saves “_subtitle = field_000001” (with the underscore).

    Even though you have a new field group with a new subtitle field, it’s not looking for “subtitle”. It is looking for “field_000001”.

    The solution is to update all of the affected posts, there is probably better solutions.

    I hope this helps people in the future, I think it is a bug but so very niche.