Support

Account

Home Forums Front-end Issues multiple value and get_field_object Reply To: multiple value and get_field_object

  • @moud,

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

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

    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 ');