Support

Account

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.