Skip Navigation

[Resolved] Use PHP to get parent post of a repeating field group

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 3 months, 3 weeks ago.

Assisted by: Waqar.

Author
Posts
#2676698

I am trying to write a function which includes getting the parent for each of a set of repeating field groups.

The RFG is called days1 and the parents are a CPT called show.

I can't seem to get anything to work using the documentation.

I have tried

$parent_posts = toolset_get_related_posts( get_the_ID(), 'show-days1', array( 'query_by_role' => 'child', 'return' => 'post_object' ) );

#2676766

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

The to get the related parent post of the repeating field group item, please make sure that:

1. 'get_the_ID' is returning the current repeating field group item's post ID

AND

2. The slug of the relationship 'show-days1' is the same as the repeating field group. For example if the repeating field group slug is 'days1', then the relationship slug should also be 'days1' and not 'show-days1'.


$parent_posts = toolset_get_related_posts( get_the_ID(), 'days1', array( 'query_by_role' => 'child', 'return' => 'post_object' ) );

This same code worked on my test website.

regards,
Waqar

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.