admin管理员组文章数量:1124387
So we have configured a filter to automatically populate ACF Fields from a custom post type and we have this working for a top-level flexible content block. However, we don't seem to be able to do the same for a nested flexible content. Block.
So in the example below, block 1 etc will be it's own flexible content field with it's set of fields. I'm hoping someone has someone can help. Thanks for your time everyone
add_filter('acf/load_value/name=driving_for_work_policy_v2', 'add_starting_repeaterv2', 10, 3);
function add_starting_repeaterv2($value, $post_id, $field) {
if ($value !== NULL) {
// $value will only be NULL on a new post
return $value;
}
// add default layouts
$value = array(
array(
//add block 1 This is also flexible with its own set of fields we need to auto populate. How do we reference this as a flex field and not just as a field of the parent.
'acf_fc_layout' => 'policy_statement',
),
array(
//add block 2
'acf_fc_layout' => 'the_driver'
),
array(
//add block 3
'acf_fc_layout' => 'the_vehicle'
),
array(
//add block 4
'acf_fc_layout' => 'the_journey'
),
array(
//add block 5
'acf_fc_layout' => 'grey_fleet_drivers'
),
array(
//add block 6
'acf_fc_layout' => 'additional_section'
),
);
return $value;
}
本文标签: phpAdvanced Custom Fields Auto Populating Field Values For Nested Repeater FIelds
版权声明:本文标题:php - Advanced Custom Fields Auto Populating Field Values For Nested Repeater FIelds 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736628836a1945732.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论