本文介绍了如何从另一个高级自定义字段获取高级自定义字段选择值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
推荐答案
要自动填充ACF中的选择字段,可以使用load_field函数-在此处查看更多信息:
To auto populate select fields in ACF, you can use the load_field function - see more here: http://www.advancedcustomfields.com/resources/acfload_field/
因此,假设您选择的字段名称是 marke_name ,则可以将以下内容添加到您的functions.php文件中,这将每次为您填充该字段
So, let's say your select field name was marke_name, you could add the following to your functions.php file and this will populate the field every time for you
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');
这篇关于如何从另一个高级自定义字段获取高级自定义字段选择值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!