starbuck2k12
Member
Posted 3 months ago #
how do I display a single field of a custom field with values repeatable?
with
<? php print_custom_field ('fieldName');?>
print all the values of the custom field but I want to print only the first
http://wordpress.org/extend/plugins/custom-content-type-manager/
If you only want the first item, then you'll have to handle the output manually. As mentioned in your other thread, a repeatable field (or any field that stores multiple values) stores its data as a JSON array. You can use json_decode() to manually convert the string stored in the database, or use the CCTM's output filters to help you, e.g. https://code.google.com/p/wordpress-custom-content-type-manager/wiki/to_array_OutputFilter
<?php
$array = get_custom_field('fieldName:to_array');
print $array[0]; // prints the 1st element of the array
?>