Repeater field mapping
Map WordPress ACF Repeater fields to components and references in Optimizely CMP for structured data integration.
Optimizely Content Marketing Platform (CMP) supports mapping the ACF Repeater field to the structured content Component and Reference type fields.
Create the structured content component first, then add the appropriate fields.
Example
You created a component called ACF Repeater with two text type fields, Name and Address.
Add this Component to the structured content as a Reference field.
NoteToggle Allow multiple entries to On.
JSON example to create the component
{
"details": {
"name": "ACF Repeater",
"component": true,
"disabled": false
},
"source": "wordpress",
"source_id": null,
"source_metadatata": null,
"created_by": "<user_guid>",
"field_definitions": [
{
"core": {
"key": "name",
"name": "Name",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 1,
"max_list_length": -1, // no max length limit
"field_type": "text-field",
"source_id": null,
"source_metadata": "{\"is_custom_post_type_field\": true}", // It is important to identify source_metadata as custom field
"order_index": 0,
"help_text": null,
"editor_metadata": null
},
"validation_pattern": ".*", // Validation required. Here it will accept anything but we can define our own validation
"min_length": 0,
"max_length": -1, // no max length limit
"default_values": null
},
{
"core": {
"key": "address",
"name": "Address",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 1,
"max_list_length": -1, // no max length limit
"field_type": "text-field",
"source_id": null,
"source_metadatata": "{\"is_custom_post_type_field\": true}", // It is important to identify source_metadata as custom field
"order_index": 1,
"help_text": null,
"editor_metadata": null
},
"validation_pattern": ".*", // Validation required. Here it will accept anything but we can define our own validation
"min_length": 0,
"max_length": -1, // no max length limit
"default_values": null
}
]
}JSON example to add a reference field
{
"core": {
"key": "acf_repeater_field",
"name": "ACF Repeater Field",
"is_list": true,
"is_required": false,
"need_internationalization": false,
"min_list_length": 1,
"max_list_length": -1,
"field_type": "content-type",
"source_id": null,
"source_metadata": "{\"is_custom_post_type_field\": true, \"type\": \"repeater\"}", // It is important to identify source_metadata as custom field and also add type as repeater
"order_index": 0,
"help_text": null,
"editor_metadata": null
},
"allowed_content_types": ["<repeater_component_guid>"],
"ref_type": 3, // 3 Means it will create new every time
"allow_ref_edit": false,
"default_value": null
}Updated 3 days ago