I have been stuck with this for a month or so now and am running out of time to complete!
Basically (please see print_R below) I have a post type called ‘Penguin’ that i have created in ACF. The functionality of my site allows these ‘Penguins’ to enter swimming competitions, i have another post type called ‘event’ which is the event they will enter. I have a post type called Fixture that has a repeater called ‘event_selector’. The ‘event’ post type is a post object that is repeated, and then a repeater field called ‘standings’ within that. Within this repeater field is the ‘Penguin’ post object.
When using the backend to add and update events with penguins it works perfectly, but when trying to update on the front end using update_field()/update_sub_field() nothing happens! I have no idea how to go ahead with trying to solve this. I have added a print_r of the repeater fields and the code i am trying to use to update the fields to add more penguins, I hope someone can help!
<?php
$fixtureArgs = array(
'post_type' => 'fixture',
'post_id' => $fixtureID );
$fixtureLoop = new WP_Query($fixtureArgs);
if($fixtureLoop->have_posts()) :
while($fixtureLoop->have_posts()) : $fixtureLoop->the_post();
if(get_the_ID() == $fixtureID) :
$field_key = 'event_selector';
$post_id = $childID;
$value = get_field($field_key, $post_id);
$value[] = array(
'standings' => array(array('penguin' => $value))
);
update_field($field_key, $value, $post_id);
endif;
endwhile;
endif;
print_r:
<?php
print_r:
(
[0] => Array
(
[event] => WP_Post Object
(
[ID] => 526
[post_author] => 1
[post_date] => 2015-05-26 15:38:04
[post_date_gmt] => 2015-05-26 15:38:04
[post_content] =>
[post_title] => 100m IM
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => 100m-im
[to_ping] =>
[pinged] =>
[post_modified] => 2015-05-26 15:38:04
[post_modified_gmt] => 2015-05-26 15:38:04
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://wcpsc.users41.interdns.co.uk/?post_type=event&p=526
[menu_order] => 0
[post_type] => event
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
[event_time] => 12.00pm
[standings] => Array
(
[0] => Array
(
[penguin] => WP_Post Object
(
[ID] => 440
[post_author] => 1
[post_date] => 2015-02-17 12:34:31
[post_date_gmt] => 2015-02-17 12:34:31
[post_content] =>
[post_title] => Alex Lancaster
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => alex-lancaster
[to_ping] =>
[pinged] =>
[post_modified] => 2015-05-20 13:53:42
[post_modified_gmt] => 2015-05-20 13:53:42
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://wcpsc.ice/?post_type=penguin&p=440
[menu_order] => 0
[post_type] => penguin
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
[time] =>
)
[1] => Array
(
[penguin] => WP_Post Object
(
[ID] => 453
[post_author] => 1
[post_date] => 2015-05-20 13:15:56
[post_date_gmt] => 2015-05-20 13:15:56
[post_content] =>
[post_title] => Bob Saget
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => bob-saget
[to_ping] =>
[pinged] =>
[post_modified] => 2015-05-21 14:03:43
[post_modified_gmt] => 2015-05-21 14:03:43
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://wcpsc.users41.interdns.co.uk/?post_type=penguin&p=453
[menu_order] => 0
[post_type] => penguin
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
[time] =>
)
[2] => Array
(
[penguin] => WP_Post Object
(
[ID] => 481
[post_author] => 1
[post_date] => 2015-05-26 12:32:35
[post_date_gmt] => 2015-05-26 12:32:35
[post_content] =>
[post_title] => Daughter
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => daughter
[to_ping] =>
[pinged] =>
[post_modified] => 2015-05-26 12:32:35
[post_modified_gmt] => 2015-05-26 12:32:35
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://wcpsc.users41.interdns.co.uk/?post_type=penguin&p=481
[menu_order] => 0
[post_type] => penguin
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
[time] =>
)
[3] => Array
(
[penguin] => WP_Post Object
(
[ID] => 439
[post_author] => 1
[post_date] => 2015-02-17 12:33:54
[post_date_gmt] => 2015-02-17 12:33:54
[post_content] =>
[post_title] => Little Jimmy
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => little-jimmy
[to_ping] =>
[pinged] =>
[post_modified] => 2015-05-21 14:01:44
[post_modified_gmt] => 2015-05-21 14:01:44
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://wcpsc.ice/?post_type=penguin&p=439
[menu_order] => 0
[post_type] => penguin
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
[time] =>
)
[4] => Array
(
[penguin] => WP_Post Object
(
[ID] => 455
[post_author] => 1
[post_date] => 2015-05-21 14:05:16
[post_date_gmt] => 2015-05-21 14:05:16
[post_content] =>
[post_title] => The Master Chief
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => the-master-chief
[to_ping] =>
[pinged] =>
[post_modified] => 2015-05-22 11:24:22
[post_modified_gmt] => 2015-05-22 11:24:22
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://wcpsc.users41.interdns.co.uk/?post_type=penguin&p=455
[menu_order] => 0
[post_type] => penguin
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
[time] =>
)
)
)
)
?>