Php 更新嵌套中继器中的Post对象高级自定义字段
我已经被困在这一个月左右了,现在没有时间完成了 基本上(请参见下面的打印)我有一个在ACF中创建的名为“企鹅”的帖子类型。我的网站的功能允许这些“企鹅”参加游泳比赛,我有另一个帖子类型叫做“事件”,这是他们将参加的事件。我有一个名为Fixture的post类型,它有一个名为“event_selector”的中继器。“event”post类型是一个重复的post对象,然后是其中一个名为“standings”的repeater字段。在此repeater字段中是“Penguin”post对象 当使用后端添加和更新penguins事件时,它工作得非常好,但是当尝试使用update_field()/update_sub_field()在前端更新时,什么都不会发生!我不知道如何着手解决这个问题。我已经添加了一个repeater字段的print\r和我试图用来更新字段以添加更多企鹅的代码,我希望有人能帮助我Php 更新嵌套中继器中的Post对象高级自定义字段,php,wordpress,advanced-custom-fields,Php,Wordpress,Advanced Custom Fields,我已经被困在这一个月左右了,现在没有时间完成了 基本上(请参见下面的打印)我有一个在ACF中创建的名为“企鹅”的帖子类型。我的网站的功能允许这些“企鹅”参加游泳比赛,我有另一个帖子类型叫做“事件”,这是他们将参加的事件。我有一个名为Fixture的post类型,它有一个名为“event_selector”的中继器。“event”post类型是一个重复的post对象,然后是其中一个名为“standings”的repeater字段。在此repeater字段中是“Penguin”post对象 当使用后
<?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;
<?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] =>
)
)
)
)
?>