Support

Account

Home Forums Backend Issues (wp-admin) Repeater field returning repeater count until post is saved via admin screen Reply To: Repeater field returning repeater count until post is saved via admin screen

  • Hi @hyperarts

    Thanks for sharing your workaround.

    Like I said before, “_primary” is the reference key of the repeater field in the database. Please take a look at this page once more: https://www.advancedcustomfields.com/resources/update_field/#field_key-vs%20field_name.

    When you use the update_sub_field() function, it creates the reference for the subfield in the database, but not for the repeater itself.

    Another workaround, you can use the update_field() function and pass an empty array to it before the update_sub_field() loop. Maybe something like this:

    update_field( 'field_559eee03f62d2', array(), $post_id );

    That way, the repeater will be initialized first and have the reference key and an empty value.

    I hope this makes sense. Thanks!