Skip to content
Matth_eu edited this page Sep 24, 2013 · 8 revisions

Any field can be made repeatable. This means that an editor can clone the field to enter multiple values for the same field.

To create a repeatable field, set 'repeatable' => true when setting field args.

Repeatable fields are stored as multiple meta entries using the same key.

When using repeatable you can also set repeatable_max to restrict the number of repeatable fields that can be created.

Example Usage

array( 
	'id'             => 'example-field-text', 
	'name'           => 'A simple text input', 
	'type'           => 'text', 
	'repeatable'     => true, 
	'repeatable_max' => 5 
),

Using repeatable field data in your theme

// Note 3rd param is false to retrieve all meta entries with the same key (Default is false)
$field_data = get_post_meta( get_the_id(), 'example_repeatable_field', false ); 

foreach ( $field_data as $single_field )
    echo $single_field;