I’ve been suck on this for a couple days, and its such an integral part of the project I thought I’d ask for help.
I have read through the guide here on bi-directional relationships, but I can’t get it to work. I’m not great with PHP, I just know enough to get by ;). That probably has created my problem, but I feel like if someone could point me in the right direction, I could make it work.
Here’s my setup.
I have a CPT called “People”. I have a field group for this custom post type which holds a ‘group’, fieldname whp_parents and a repeater, fieldname ‘spouses’. Basically, I need bidirectional relationships between parents, spouses, and children. So, if I add a child to a person, they are automatically added as a parent, vise versa and etc.
In the whp_parents group, I have a post object for ‘father’, and a post object for ‘mother’, which need to relate to the ‘children’ post object in the ‘spouses’ repeater. (I have a field in a different group for gender, which will help me determine whether to add a person as a father or mother.)
In the ‘spouses’ repeater, I have a group ‘spouse’ for the spouse information. In that group I have a ‘spouse’ post object. (I know, confusing. I should have named them differently.) Since this is relating to a field of the same name, I feel like this one shouldn’t be as difficult, but the repeater is throwing me for a loop.
Children are also in the ‘spouses’ repeater, under a post-object field (will return an array for multiple children of a marriage).
I’m not sure if its all of the different fields that have to work together that has me so confused, or if its because of the repeaters and arrays, but I am completely stuck.
I would be more than grateful for any hints, tips, logic, or other knowledge anyone could share. Thanks!