Home Forums Bug Reports Export/import field groups makes image fields return ID instead of array Reply To: Export/import field groups makes image fields return ID instead of array

  • This is a pretty common problem for me, and it happens on many different WordPress installs. I’d say it’s been happening for about a year, but it’s probably more like 1.5 years since Covid has screwed up my sense of time. I’m usually exporting locally and importing to a dev server. I always first delete the field group on the dev server, then import the json from my local install. The imported image fields will then only return IDs instead of arrays. It doesn’t happen with all image fields though. For the affected fields, I need to change them to return ID, save, then change back to array, save, and then the problem is usually fixed.

    This last one was being extremely stubborn and wouldn’t fix when changing the return type, but it was a somewhat unique use case. It was a disabled field group that was included in another field group as a Clone field (seamless replace). I deleted both field groups and reimported many times, and changed the return type many times. No matter what the image field would only return an array, not an ID (in this case I wanted the ID returned, not array.) Eventually I tried what I talked about above and that fixed it (exporting json, changing characters in the field key, and importing the modified json). Luckily I wasn’t using any hard-coded field keys anywhere so it immediately started working correctly.

    By the way, I want to add that when this problem happens, it always reverses the output type. If it’s set to an array, it will return an ID. If it’s set to an ID it will return an array. It seems to me that somewhere in the import process the return types get mixed up. The admin UI still shows the correct return type though (the correct radio button is selected), it just returns the wrong value.