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' ) );
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