Home Forums Add-ons Repeater Field Add Row only works on published cpt's


Add Row only works on published cpt's

  • Hi I use Add Row to add data to a repeater in a custom post type however… it only adds and returns correctly when the post in question is published.

    Any reason why? I dont want these posts published but I need to add the data.


  • Hi @snixx

    I’ve just tested it on my installation and it was working on my drafted custom post type, both the add_row() and get_field() functions.

    Did you add the new post programmatically? If you did, it’s possible that your post doesn’t have the repeater value in the database yet. Keep in mind that the add_row() function will only add a row to an existing repeater. I think you can use the update_field to add an empty value. This page should give you more idea about it:

    Hope this helps.

  • Hi James yes they are programmatically added.

    So I create my posts and then immediately after I iterate over my data and add the content into the repeater fields.

    Odd thing is I can go into the admin for a post and the repeater is there however no data will be added to it (add row) while it’s not set to published.

  • Hi @snixx

    It’s because ACF will show the repeater field based on your field group setting, but it still has no initial value in the database. It will prevent the add_row() function to add the row because it can’t find it.

    Have you tried the update_field() function instead?


  • Hey again, no go on that one – failed like add row on the unpublished ones.

    What I have ended up doing is manually inserting the fields key (getting the acf field key from the database and not hardcoding it) into the meta posts table if its missing and then importing my repeater data – this works fine.


Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Add Row only works on published cpt's’ is closed to new replies.