Skip Navigation

[Resolved] Access the "Repeatable Field Groups" of a post

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

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 1 reply, has 2 voices.

Last updated by Minesh 4 years ago.

Assisted by: Minesh.

Author
Posts
#1891201

Hi there,
I have set up a custom post type (Channels) and created custom fields including repeatable field groups (RFG slug: length-groups ) too. I am using the following code to access the RFG.

$length_post_ids = toolset_get_related_posts(
$channel, // the parent post POST obj
'length-groups', // the RFG slug
'parent', // the post role in this relationship is 'parent'
1000000, // the maximum number of results
0, // the offset
array(), // additional query arguments
'post_id', // return format
'child' // role to return
);

but $length_post_ids is returning an empty array.

Versions:
PHP: 7.2
WordPress: 5.6
Toolset Types: 3.4.5

I am wondering if you can help me with this. Let me know if you need the website's backend access.

Thanks
Sohaib

#1892029

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

With the following line of code:

$channel, // the parent post POST obj

Can you please make sure you pass the channel ID.

This is your original code:

$length_post_ids = toolset_get_related_posts(
$channel->ID, // the parent post POST obj
'length-groups', // the RFG slug
'parent', // the post role in this relationship is 'parent'
1000000, // the maximum number of results
0, // the offset
array(), // additional query arguments
'post_id', // return format
'child' // role to return
);

Does it works?

More info:
=> https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts