Created
March 9, 2016 18:28
-
-
Save tripflex/e4d6330f38fd18b60d30 to your computer and use it in GitHub Desktop.
Output standard text field with space or comma separated values with line break (or custom HTML) after each item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment