Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Affichage des valeurs d'un champ ACF quel que soit sont type (string, checkbox, select...)
- function the_field_values($field_name,$sep=', ',$echo=true) {
- $ret = '';
- $field = get_field_object($field_name);
- if (is_array($field['value'])) {
- for ($i=0; $i<count($field['value']); $i++)
- if ($field['choices'][$field['value'][$i]])
- $ret .= ($ret?$sep:'').$field['choices'][$field['value'][$i]];
- elseif ($field['value'])
- $ret .= ($ret?$sep:'').$field['value'];
- }
- else {
- $ret = $field['choices'][$field['value']]?:$field['value'];
- }
- if ($echo)
- echo $ret;
- else
- return $ret;
- }
- // Récupération des valeurs d'un champ ACF quel que soit sont type (string, checkbox, select...)
- function get_the_field_values($field_name,$sep=', ') {
- return the_field_values($field_name,$sep,false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement