Output standard text field with space or comma separated values with line break (or custom HTML) after each item

content-single-job_listing.php

<?php

$field_values = get_custom_field( 'field_meta_key' );

if( ! empty( $field_values ) ){
	
	// The default in code below is to output a line break HTML (<br />) after each item,
	// if you want to use something else or different HTML, just replace <br /> below
	

    // Use this to support "one two three four" ... values separated by space
    // Remove the "//" before $field_values right below this line, and comment out the $field_values about 3 or 4 lines down
    //$field_values = str_replace( " ", "<br />", $field_values );

    // Use this to support "one, two, three, four" and "one,two,three,four" ... values separated by comma (with or without space)
    $field_values = str_replace(" ", "", str_replace( ",", "<br />", $field_values ) );

    echo $field_values;
}
No comments yet.

Leave a Reply