Home Forums Front-end Issues multiple value and get_field_object


multiple value and get_field_object

  • Hello Elliot
    I would like to retrieve multiple values ​​from a select field.

    I use “get_field_object” for the label and value.

    Everything works fine on the rest except when I select multiple values.
    it makes me a “array”

    Here is my code.

                $technologie_de_lecture = "technologie_de_lecture";
                $field = get_field_object($technologie_de_lecture);
                echo '
                    <div id="container-caracteristiques-fiches-produits">
                        <span id="titre-caracteristiques-fiches-produits">'.$field['label'].'</span><br />

    thank you very much

  • @moud,

    You’ll have to loop through array values – for example:

    foreach($field['value'] as $value):
      echo $value . '<br>';

    Or, here’s a function I use often to output a human-readable a comma-separated list:

    // Place in functions.php
    function implode_nice($array, $separator = ', ', $last_separator = ' & ') {
    	if ( count( $array ) == 1 ) {
    		return reset( $array );	
    	$end_value = array_pop( $array );				
    	$list = implode( $separator, $array );			
    	return $list . $last_separator . $end_value;			
    // Use in template like:
    echo implode_nice($field['value'], ', ', ' and ');
  • Hi @moud

    Did @wells5609 reply solve your question?

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘multiple value and get_field_object’ is closed to new replies.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.