要自动填充ACF中的选择字段,您可以使用load_field函数-在此处查看更多信息:http : //www.advancedcustomfields.com/resources/acfload_field/
因此,假设您选择的字段名称为marke_name,则可以将以下内容添加到functions.php文件中,这将每次为您填充该字段
function acf_load_marke_name_field_choices($field)
{
global $post;
//Get the repeater field values
$choices = get_field('repeater_field_name',$post->ID);
// loop through array and add to field 'choices'
if (is_array($choices)) {
foreach ($choices as $choice) {
//Set the select values
$field['choices'][$choice['slug']] = $choice['name'];
}
}
// return the field
return $field;
}
add_filter('acf/load_field/name=marke_name', 'acf_load_marke_name_field_choices');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句