Create structured content for WordPress
Add structured content for WordPress in Optimizely Content Marketing Platform (CMP).
Optimizely Content Marketing Platform (CMP) supports adding structured content from the Open API for WordPress Advanced Custom Fields (ACF).
Use POST https://api.cmp.optimizely.com/structured-content/content-types to create the structured content. See the API reference for information.
You must have the following mandatory fields in the structured content, along with other ACF fields and taxonomy:
- Webpage Analytics
- Body
- Featured Image
- WordPress Meta Info
Webpage Analytics
This is automatically created for your organization.
Click Webpage Analytics to see the details.
Copy the GUID from the URL.
JSON example
Use the structured content Reference field to add the webpage analytics.
{
"core": {
"key": "webpage",
"name": "WebpageAnalytics",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 0,
"max_list_length": -1,
"field_type": "content-type",
"source_id": null,
"source_metadata": null,
"order_index": 0,
"help_text": null,
"editor_metadata": null
},
"allowed_content_types": ["<GUID_COPIED_FROM_URL>"],
"ref_type": 3,
"allow_ref_edit": true,
"default_value": null
}Body
This is a Rich Text field.
JSON example
{
"core": {
"key": "body",
"name": "Body",
"is_list": false,
"is_required": true,
"need_internationalization": false,
"min_list_length": 0,
"max_list_length": -1,
"field_type": "rich-text",
"source_id": null,
"source_metadata": "{\"is_custom_post_type_field\": false}", // Adding this is not mandatory but recommended
"order_index": 1,
"help_text": null,
"editor_metadata": null
},
"min_visual_text_length": 1,
"max_visual_text_length": -1,
"default_values": null
}Featured Image
This is an Asset field for Image type.
JSON example
{
"core": {
"key": "featuredImage",
"name": "Featured Image",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 0,
"max_list_length": -1,
"field_type": "library-asset",
"source_id": null,
"source_metadata": "{\"is_custom_post_type_field\": false}", // Adding this is not mandatory but recommended
"order_index": 2,
"help_text": null,
"editor_metadata": null
},
"allowed_types": ["image"],
"default_values": null
}WordPress Meta Info
The WordPress Meta Info should be automatically created from your Wordpress connection. If not, contact Optimizely Support, or create it by using Open API. See the following JSON example to create WordPress Meta Info.
ImportantDo not create the WordPress Meta Info component if it is already created by the system.
Click WordPress Meta Info to see details.
Copy the GUID from the URL.
JSON example
{
"core": {
"key": "wpMetaInfo",
"name": "WordPress Meta Info",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 0,
"max_list_length": -1,
"field_type": "content-type",
"source_id": null,
"source_metadata": null,
"order_index": 14,
"help_text": null,
"editor_metadata": null
},
"allowed_content_types": ["<wordpress_meta_info_component_guid>"],
"ref_type": 3,
"allow_ref_edit": true,
"default_value": null
}Full JSON Payload
Use https://api.cmp.optimizely.com/v3/structured-content/content-types to create a WordPress Meta Info component. See the API reference for information.
{
"details": {
"name": "WordPress Meta Info",
"component": true,
"disabled": false
},
"source": "Welcome",
"source_id": "wp_meta_info",
"source_metadata": null,
"created_by": "<user_guid>",
"field_definitions": [
{
"core": {
"key": "wpMetaTitle",
"name": "Meta Title",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 1,
"max_list_length": -1,
"field_type": "text-field",
"source_id": null,
"source_metadata": null,
"order_index": 0,
"help_text": null,
"editor_metadata": null
},
"validation_pattern": ".*",
"min_length": 0,
"max_length": -1,
"default_values": null
},
{
"core": {
"key": "wpMetaDescription",
"name": "Meta Description",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 1,
"max_list_length": -1,
"field_type": "text-field",
"source_id": null,
"source_metadata": null,
"order_index": 1,
"help_text": null,
"editor_metadata": null
},
"validation_pattern": ".*",
"min_length": 0,
"max_length": -1,
"default_values": null
}
]
}Full example
This includes Webpage Analytics, Body, Featured Image, Authors, Tags, and Category.
{
"details": {
"name": "WordPress ACF Enabled Post Types",
"component": false,
"disabled": false
},
"source": "wordpress",
"source_id": "<integration_guid>",
"source_metadata": "{\"name\":\"<custom_post_type_name>\"}",
"created_by": "<user_id>",
"field_definitions": [
{
"core": {
"key": "webpage",
"name": "WebpageAnalytics",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 0,
"max_list_length": -1,
"field_type": "content-type",
"source_id": null,
"source_metadata": null,
"order_index": 0,
"help_text": null,
"editor_metadata": null
},
"allowed_content_types": ["<webpage_analytics_component_guid>"],
"ref_type": 3,
"allow_ref_edit": true,
"default_value": null
},
{
"core": {
"key": "body",
"name": "Body",
"is_list": false,
"is_required": true,
"need_internationalization": false,
"min_list_length": 0,
"max_list_length": -1,
"field_type": "rich-text",
"source_id": null,
"source_metadata": "{\"is_custom_post_type_field\":false}",
"order_index": 1,
"help_text": null,
"editor_metadata": null
},
"min_visual_text_length": 1,
"max_visual_text_length": -1,
"default_values": null
},
{
"core": {
"key": "category",
"name": "Category",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 1,
"max_list_length": -1,
"field_type": "json",
"source_id": null,
"source_metadata": null,
"order_index": 4,
"help_text": null,
"editor_metadata": {
"editorGuid": "<remote_field_guid>",
"editorConfig": {
"taxonomy": "category",
"isMultiSelect": true,
"integrationInstanceId": "<integration_guid>"
}
}
},
"base_type": "json",
"default_values": null
},
{
"core": {
"key": "featuredImage",
"name": "Featured Image",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 0,
"max_list_length": -1,
"field_type": "library-asset",
"source_id": null,
"source_metadata": "{\"is_custom_post_type_field\":false}",
"order_index": 2,
"help_text": null,
"editor_metadata": null
},
"allowed_types": ["image"],
"default_values": null
},
{
"core": {
"key": "author",
"name": "Authors",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 1,
"max_list_length": -1,
"field_type": "json",
"source_id": null,
"source_metadata": "{\"is_custom_post_type_field\":true}",
"order_index": 3,
"help_text": null,
"editor_metadata": null
},
"base_type": "json",
"default_values": null
},
{
"core": {
"key": "tags",
"name": "Tags",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 1,
"max_list_length": -1,
"field_type": "json",
"source_id": null,
"source_metadata": null,
"order_index": 5,
"help_text": null,
"editor_metadata": {
"editorGuid": "<remote_field_guid>",
"editorConfig": {
"taxonomy": "post_tag",
"isMultiSelect": true,
"integrationInstanceId": "<integration_guid>"
}
}
},
"base_type": "json",
"default_values": null
},
{
"core": {
"key": "wpMetaInfo",
"name": "WordPress Meta Info",
"is_list": false,
"is_required": false,
"need_internationalization": false,
"min_list_length": 0,
"max_list_length": -1,
"field_type": "content-type",
"source_id": null,
"source_metadata": null,
"order_index": 14,
"help_text": null,
"editor_metadata": null
},
"allowed_content_types": ["<wordpress_meta_info_component_guid>"],
"ref_type": 3,
"allow_ref_edit": true,
"default_value": null
}
]
}Update structured content
You can update structured content for WordPress by using POST /structured-content/content-types/{content_type_id}/versions.
Remote fields
CMP remote fields power the WordPress v2 ACF fields on the backend. See Remote fields to learn more.
Updated 2 days ago