如何获得具体价值?

时间:2014-12-26 18:54:52

标签: wordpress

如何从meta_value中仅获取标签值Button Url?

METAVALUE:

a:14:{s:3:"key";s:19:"field_549d97643254d";s:5:"label";s:10:"Button Url";s:4:"name";s:10:"button_url";s:4:"type";s:4:"text";s:12:"instructions";s:0:"";s:8:"required";s:1:"1";s:13:"default_value";s:0:"";s:11:"placeholder";s:0:"";s:7:"prepend";s:0:"";s:6:"append";s:0:"";s:10:"formatting";s:4:"html";s:9:"maxlength";s:0:"";s:17:"conditional_logic";a:3:{s:6:"status";s:1:"0";s:5:"rules";a:1:{i:0;a:3:{s:5:"field";s:19:"field_549d944402ae6";s:8:"operator";s:2:"==";s:5:"value";s:3:"Yes";}}s:8:"allorany";s:3:"all";}s:8:"order_no";i:10;}

1 个答案:

答案 0 :(得分:0)

由于您使用的是高级自定义字段,因此get_field_object具有一个函数,该函数返回一个数组,其中标签的键带有标签'。

所以:

$field = get_field_object('field_549d97643254d');
$label = $field['label']; // "Button Url"

请参阅此处的ACF文档: http://www.advancedcustomfields.com/resources/get_field_object/