WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. starbuck2k12
    Member
    Posted 1 year 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/

  2. fireproofsocks
    Member
    Plugin Author

    Posted 1 year 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

    <?php
    $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