相关疑难解决方法(0)

如何从WordPress数据库获取高级自定义字段字段键?

我正在使用带有post-type的高级自定义字段.我有一些选择自定义字段,我想显示每个字段的所有标签选项.

我试过这种方式.

$field = get_field_object('hair_color');
$hair = $field["choices"];
    foreach($hair as $value){
Run Code Online (Sandbox Code Playgroud)

做一个

后续代码var_dump($场)

它似乎是空的:

array(18) { 
   ["key"] => string(16) "field_hair_color" 
   ["label"] => string(0) "" 
   ["name"] => string(10) "hair_color" 
   ["_name"] => string(10) "hair_color" 
   ["type"]=> string(4) "text" 
   ["order_no"]=> int(1) 
   ["instructions"]=> string(0) "" 
   ["required"]=> int(0) 
   ["id"] => string(20) "acf-field-hair_color" 
   ["class"] => string(4) "text" 
   ["conditional_logic"] => array(3) { 
        ["status"] => int(0) 
        ["allorany"]=> string(3) "all" 
        ["rules"]=> int(0) 
   } 
   ["default_value"] => string(0) "" 
   ["formatting"] => string(4) "html" 
   ["maxlength"] => string(0) "" 
   ["placeholder"] => string(0) "" 
   ["prepend"] …
Run Code Online (Sandbox Code Playgroud)

wordpress custom-fields advanced-custom-fields

20
推荐指数
5
解决办法
2万
查看次数