ラベルを短いコードで取得したいです。
php
1$example = get_field('example-name'); 2<h1><? echo $example; ?></h1>
上のように記述すると、LabelではなくNameが返ってくるので、
php
1$exampleField = get_field_object('example-name'); 2$exampleValue = get_field('example-name'); 3$exampleLabel = $exampleField['choices'][ $exampleValue ];
このように書き、
php
1<?php echo $exampleLabel;?>
と毎回書くのですが、長いので短くしたいです。
functionを作ろうかとも思いましたが、プログラミング初心者で記述方法がイマイチわかりません。
短く書く方法か、functionの書き方を教えていただけないでしょうか?
よろしくお願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/02/25 16:49
2016/02/26 01:01