Home › Forums › Add-ons › Repeater Field › Adding subfields to Repeater Field › Reply To: Adding subfields to Repeater Field
Ok, I have finally figured it out – this is what tripped me up:
– Field key isn’t generated until you add something via the GUI, once you do this you can find it in the database, I think the docs mention this.
– If its a subfield of a repeater field you are adding too, you need 2 keys, the first is for the repeater field, the second is the subfield. So the code to do this looks like:
update_sub_field(array('field_55fcc711c095d', 1, 'field_55fcc726c095e'),20956, 20967);
Where 20956 is an attachment id of an image, and 20967 is the post id for testing purposes.
This however Will not work Unless I add one image manually through the GUI.
———— UPDATE ————–
I worked out a workaround for the page by querying directly:
select * from wp_postmeta where post_id=$post_id AND meta_key LIKE 'images_%image%'
This query gets all the fields I need out, and I can retrieve the attachment IDs from it. This works fine for the page – however on the exact same post in the edit screen I cant see the images in the repeater field.
TL;DR – They are in the DB, I can get them on the page, but they don’t appear on the edit screen and aren’t retrievable using the_repeater_field.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.