Repeating user fields can have more than one value. Types let you create repeating user fields.
Repeating user fields are useful when you need to include several instances of the same field. For example, people might have several phone numbers or addresses.
When creating a user field you can define it as repeating by selecting the Allow multiple-instances of this field option in the Single or repeating field section.
When you select Allow multiple-instances of this field, the content edit screen will include the Add new button. Click this button to add more values to your field.
Here is how it looks like:
Types API will load all values for repeating fields and display them one after the other. You can specify the separator that goes between items.
Let’s consider the following code:
[types usermeta="phone-number" separator=", " user_is_author="true"][/types]
It will output something like this:
+1-202-555-0155, +1-202-555-0101, +1-202-555-0203, +1-202-555-0123
The following code:
<ul> <li>[types usermeta="phone-number" separator="</li><li>" user_is_author="true"][/types]</li> </ul>
… will output an unordered list:
While this code:
<ol> <li>[types usermeta="phone-number" separator="</li><li>" user_is_author="true"][/types]</li> </ol>
… will output an ordered list:
The index parameter will return a single value from a repeating field. This uses zero-based numbering, so the first element has an index=”0″, the third has an index=”2″, and so on.
The above example would return the second value for the phone-number repeating field.
You can change the order of the repeating field values using drag-and-drop directly from the post edit screen.
If you are using only the Types plugin, you can display repeating fields in your templates using custom PHP code. Learn more about this topic on the page about displaying repeating fields using PHP.