• Resolved Begin

    (@bentalgad)


    Is it possible to some how use update_post_meta to add a row for a repeatable field?

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Unless I’m mistaken, the initial data in the repeatable field meta key/value pair is just an array of arrays.

    $my_group = get_post_meta( get_the_ID(), 'my_group_data', true );
    $my_group[] = array( 'item_1' => 'value_1', 'item_2' => 'value_2' );
    update_post_meta( get_the_ID(), 'my_group_data', $my_group );
    

    Won’t hurt to do a var_dump or so on your initially fetched meta data to see its structure and match as such.

    Thread Starter Begin

    (@bentalgad)

    I’m not using group just single repeatable field. but got it! Thanks!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Derp @ me regarding the group part, but I have to believe the setup is still going to be the same, an array storing the content for the field. Insert a new index for the field, update. Still won’t hurt to check the structure so you can match appropriately.

    Thread Starter Begin

    (@bentalgad)

    Great. got it! Thanks again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘update_post_meta for repeatable field’ is closed to new replies.