I am trying to: retrieve data via WP API from a page that uses a repeatable field group
Link to a page where the issue can be seen: N/A private development environment
I expected to see: JSON output similar to your documentation (https://toolset.com/documentation/programmer-reference/toolset-integration-with-the-rest-api/#formatted-output-for-single-and-repeatable-fields ).
For example:
"toolset-meta": {
"hero-banner-repeating-component": {
"type": "field_type_slug",
"raw": [
"a",
"b",
"c"
],
"repeatable": [
{
"raw": "a",
"formatted_value": "a_formatted"
},
{
"raw": "b",
"formatted_value": "b_formatted"
},
{
"raw": "c",
"formatted_value": "c_formatted"
}
]
}
}
Instead, I got: An empty JSON array element. For example:
...
"toolset-meta": {
"hero-banner-repeating-component": []
},
...
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Repeatable field groups are actually managed as hidden custom post type under the hood and establish hidden one-to-many relationship to the parent post type.
- Parent post where repeating field group is displayed (parent) can have many items of repeating field group (child).
Toolset does not offer a built-in way to publish relationships through REST API. You will need to extend the WordPress API and query the data using the relationship API.
- https://developer.wordpress.org/rest-api/
- https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
Maybe following related ticket will help you to understand how it should work:
- https://toolset.com/forums/topic/writing-rfg-to-cpt-via-rest/#post-1310253
Thank you, I will try your suggestions and report back!