Custom Content Type Manager
[resolved] how to display a single field of a custom field with values ​​repeatable (2 posts)

  1. starbuck2k12
    Posted 3 years ago #

    how do I display a single field of a custom field with values ​​repeatable?


    <? php print_custom_field ('fieldName');?>

    print all the values ​​of the custom field but I want to print only the first


  2. fireproofsocks
    Plugin Contributor

    Posted 3 years ago #

    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

    $array = get_custom_field('fieldName:to_array');
    print $array[0]; // prints the 1st element of the array

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic