Home › Forums › Add-ons › Repeater Field › ACF add_row works incorrect › Reply To: ACF add_row works incorrect
Hi John, sorry for a long delay.
I tried to turn off all plugins but problem still the same.
So I have installed new wordpress and add there only one plugin ‘ACF pro’. I used ‘Twenty Fourteen’ theme and added there page with this code:
<?php
/**
* Template Name: ACF test page
*/
get_header(); ?>
<form method="POST" action="<?php the_permalink(); ?>" style="float: right;width: 200px;">
<input type="hidden" name="field_key" />
<input type="text" name="sub_field_one" />
<input type="text" name="sub_field_two" />
<input type="submit" value="Try it!" />
</form>
<div style="float: right">
<?php if($_POST): ?>
<?php
$post = array(
'post_title' => 'Title of new post',
'post_content' => '',
'post_status' => 'publish',
'post_type' => 'post'
);
$post_ID = wp_insert_post($post);
$row = array(// don't forget to change field keys
'field_56d6bdeb338e7' => $_POST['sub_field_one'],
'field_56d6be03338e8' => $_POST['sub_field_two']
);
$row_id = add_row('field_56d6bdd7338e6', $row, $post_ID);
echo $row_id;
?>
<?php endif ?>
</div>
<?php
get_sidebar();
get_footer();
Also I added ACF repeater with two text fields. So form on this page should create a new post and add there values from form to repeater subfields.
After submitting I saw an ID of new row – ‘1’ near form. But in admin panel I can’t see any value which I wrote in form.
Can you try it on your wordpress?
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.