У меня есть настраиваемое поле (созданное с помощью ACF), которое позволяет автору выбирать из нескольких параметров (в админке) и где эти варианты отображаются в интерфейсе. Код, создающий настраиваемое поле, следующий:
array ( 'key' => 'field_52dcf154e272e', 'label' => __('Selling Points', 'mytheme' ), 'name' => 'selling_points', 'type' => 'checkbox', 'instructions' => __('Check 4 items', 'mytheme' ), 'choices' => array ( 'Bed linens included key' => __('Bed linens included value', 'mytheme'), 'Full bed linens included' =>__('Full bed linens included', 'mytheme'), 'Free WIFI and Internet Access' => __('Free WIFI and Internet Access', 'mytheme' ), 'Free (in-room) WIFI' =>__('Free (in-room) WIFI', 'mytheme' ), 'Breakfast included' => __('Breakfast included', 'mytheme' ), 'Safe provided in room' => __('Safe provided in room', 'mytheme' ), 'Individual room key' => __('Individual room key', 'mytheme' ), ), 'layout' => 'vertical', ),
Проблема в том, что значение отображается в вариантах администрирования, и в настоящее время ключ отображается в интерфейсе. В шаблоне страницы у меня есть следующий код:
$count= 0; $points = get_field_object('selling_points'); foreach ( $points['value'] as $point ){ if($count < 4 ){ printf(__('<li class="bullet-item">%s</li>', 'mytheme' ), $point); $count++; } }
когда я var_dump($points)
я получаю:
Array ( [key] => field_52dcf154e272e [label] => Selling Points [name] => selling_points [_name] => selling_points [type] => checkbox [order_no] => 1 [instructions] => Check 4 items [required] => 0 [id] => acf-field-selling_points [class] => checkbox [conditional_logic] => Array ( [status] => 0 [allorany] => all [rules] => 0 ) [choices] => Array ( [Bed linens included key:] => Bed linens included value [Full bed linens included] => Full bed linens included [Free WIFI and Internet Access] => Free WIFI and Internet Access [Free (in-room) WIFI] => Free (in-room) WIFI [Breakfast included] => Breakfast included [Safe provided in room] => Safe provided in room [Individual room key] => Individual room key ) [layout] => vertical [default_value] => [value] => Array ( [0] => Bed linens included key: [1] => Free WIFI and Internet Access [2] => Petit déjeuner inclus [3] => Safe provided in room ) )
Таким образом, по-видимому, AFC получает значение на основе ключа. Как я могу затем принимать значения в массиве [value]
и преобразовывать их в вызовы gettext?