【发布时间】:2020-11-26 18:23:06
【问题描述】:
我想自定义 Yith 插件,我想为其添加一些带有现有字段的自定义字段。我从 ACF 获取字段并将它们添加到数组 ACF 字段显示在 Yith Setting 中,但只有少数字段显示在主页和其他网站页面中。
add_filter('yith_woocompare_standard_fields_array','ta_yith_woo_compare');
function ta_yith_woo_compare($fields){
$acf_fields_groups = acf_get_fields(5258);
$labels = array();
foreach($acf_fields_groups as $grp)
{
$group_id = $grp['ID'];
$sub_fields = $grp['sub_fields'];
foreach($sub_fields as $fld){
$labels[$fld['name']] = $fld['label'];
}
}
$fields =$fields + $labels;
return $fields;
}
同样,如果我打印包含所有字段的 Array Yith Setting Page 打印数组。
我不知道这是 Array 还是 ACF 的问题,请帮我解决这个问题,这是我的代码。
【问题讨论】:
-
请不要包含代码图像,您的问题应该包含代码块中格式化的代码本身。
-
我在底部添加了代码。有必要使用屏幕截图详细说明我的问题。
-
我已将代码 sn-p 移至顶部。
标签: php wordpress plugins advanced-custom-fields acfpro