Skip Navigation

[Resolved] Toolset API doesn't show repeatable groups 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.

Our next available supporter will start replying to tickets in about 0.87 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 4 replies, has 2 voices.

Last updated by FachrulH2232 1 year ago.

Assisted by: Mateus Getulio.

Author
Posts
#2663991

Tell us what you are trying to do?
I want to fetch API from Toolset
Is there any documentation that you are following?
Yes, your official documentation
Is there a similar example that we can see?
hidden link
What is the link to your site?
hidden link

#2664259

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

There isn't an exact document available for the Repeating Fields Groups API. However, it utilizes a child post type to store the Repeating Fields Groups. You can use the function toolset_get_related_posts() to retrieve the child posts and then display the custom field of each child post. Here's an example:

Create a Repeating Fields Group named "my-fields-group" within the post type "my-cpt" and add some custom fields to the field group.

In your theme file single.php, include the following code:

$child_posts = toolset_get_related_posts( 
    get_the_ID(), //Post to query by.
    'my-fields-group',  //Slug of the relationship to query by 
    'parent', //Name of the element role to query by.
    100, //Maximum number of returned results
    0, //Result offset
    array(),//Additional query arguments
    'post_id', //Determines return type
    'child' // which posts from the relationship should be returned
);
var_dump($child_posts);

As you can check, the last parameter is set to "child," which enables you to query the child posts of the current post.

Please check this documentation for more info: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

Thank you!

#2664265

Hello, I found the documentation that has the explanation for the output of repeatable fields in Toolset. It said that if the field is repeatable, it will display an array. But it doesn't displayed on my end.

Here is the documentation
https://toolset.com/documentation/programmer-reference/toolset-integration-with-the-rest-api/

#2664315

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello again,

I checked the documentation link you sent and although demonstrated how the repeatable groups would be printed if available in the output, the issue is probably because the available Toolset REST integration options are primarily focused on simple custom fields.

With regard to repeatable field groups, it's essential to understand that they are hidden custom post types, joined by a hidden one-to-many relationship with the parent post type. I'm afraid that Toolset does not provide a built-in mechanism for exposing the relationships through the REST API. To achieve this, you will need to extend the capabilities of the WordPress API and query the data using the relationship API. You can refer to the following resources for further guidance:

https://developer.wordpress.org/rest-api/
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

I hope this information helps. Please feel free to reach out if you have any further inquiries or require additional assistance.

#2665425

Just please add this feature to your roadmap.