Skip Navigation

[Resolved] Data from repeatable groups is not returned from WP Rest API

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 9 months, 1 week ago.

Assisted by: Minesh.

Author
Posts
#2684463

LCR

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": []
},

...

#2684618

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

#2684816

LCR

Thank you, I will try your suggestions and report back!

#2684893

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

ok fine.