Relationships System
Overview
Section titled “Overview”The system includes a bidirectional relationship system that automatically synchronizes relationships between people. When you create a relationship from Person A to Person B, the system automatically creates the inverse relationship from Person B to Person A.
How Relationships Work
Section titled “How Relationships Work”Storage
Section titled “Storage”Relationships are stored as an ACF (Advanced Custom Fields) repeater field on each Person post. Each relationship entry contains:
- Related Person: The ID of the person this relationship refers to
- Relationship Type: A taxonomy term ID indicating the type of relationship (Parent, Child, or Sibling)
- Custom Label: An optional override label for the relationship
Automatic Bidirectional Sync
Section titled “Automatic Bidirectional Sync”When you create, update, or delete a relationship, the system automatically:
- Creates the inverse relationship on the related person’s record
- Updates the inverse relationship if the relationship type changes
- Deletes the inverse relationship if the original is removed
The inverse relationship type is determined by the ACF field configuration on the Relationship Type taxonomy term.
Example Flow
Section titled “Example Flow”Scenario: You create a relationship where Person A is a “Parent” to Person B.
- System stores: Person A -> Person B = “Parent”
- System looks up inverse mapping: “Parent” -> “Child”
- System creates: Person B -> Person A = “Child”
Both relationships are now synchronized.
Default Relationship Types
Section titled “Default Relationship Types”Three relationship types are included by default:
Symmetric Relationships
Section titled “Symmetric Relationships”- Sibling <> Sibling (same type as inverse)
Asymmetric Relationships
Section titled “Asymmetric Relationships”- Parent <> Child (each maps to the other)
Automatic Sibling Sync
Section titled “Automatic Sibling Sync”When a parent-child relationship is created, the system automatically creates sibling relationships between all children who share the same parent. If a parent-child link is removed and the child has no remaining parents, sibling relationships are cleaned up.
Custom Relationship Types
Section titled “Custom Relationship Types”Users can add custom relationship types via Settings > Relationship Types. Each custom type can be configured with an inverse mapping:
- For symmetric types: set the inverse to the same type
- For asymmetric types: set each type’s inverse to its counterpart
- Leave the inverse empty for one-way relationships
Creating Relationships
Section titled “Creating Relationships”Via Frontend
Section titled “Via Frontend”- Navigate to a Person’s detail page
- Click “Add Relationship” in the Relationships section
- Select the related person
- Choose the relationship type
- Optionally add a custom label
- Save
The inverse relationship is created automatically.
Via WordPress Admin
Section titled “Via WordPress Admin”- Edit a Person post
- Go to the Relationships tab
- Add a relationship row
- Select person and type
- Update the post
The inverse relationship is created automatically via ACF hooks.
Via REST API
Section titled “Via REST API”When updating a person’s relationships field via REST API, the inverse relationships are automatically synchronized.
Editing Relationships
Section titled “Editing Relationships”When you edit a relationship:
- Change the person: Old inverse is deleted, new inverse is created
- Change the type: Old inverse type is removed, new inverse type is created
- Change the label: Label is copied to the inverse relationship
Deleting Relationships
Section titled “Deleting Relationships”When you delete a relationship, the corresponding inverse relationship is automatically removed from the related person’s record.
Edge Cases
Section titled “Edge Cases”Missing Inverse Mapping
Section titled “Missing Inverse Mapping”If a relationship type doesn’t have an inverse mapping configured, no inverse relationship will be created. This is useful for one-way relationships or when you want to manually manage inverses.
Circular References
Section titled “Circular References”The system prevents infinite loops when syncing relationships. If Person A and Person B are being updated simultaneously, the sync process tracks which posts are being processed to avoid circular updates.
Missing People
Section titled “Missing People”If the related person doesn’t exist or isn’t accessible, the inverse relationship creation is skipped.
Best Practices
Section titled “Best Practices”- Always set inverse mappings: Configure inverse relationships for all relationship types you use
- Keep mappings consistent: Ensure bidirectional mappings are set up correctly (if A->B maps to C, then C->A should map back to A’s type)
- Test relationships: After configuring new relationship types, test that inverses are created correctly
Troubleshooting
Section titled “Troubleshooting”Inverse relationship not created
Section titled “Inverse relationship not created”- Check that the relationship type has an inverse mapping configured in Settings > Relationship Types
- Verify both people exist and are accessible
- Check for JavaScript errors in the browser console
Wrong inverse type created
Section titled “Wrong inverse type created”- Verify the inverse mapping is correct in Settings > Relationship Types
- Check that the relationship type taxonomy terms exist
Duplicate relationships
Section titled “Duplicate relationships”- The system prevents duplicates automatically
- If duplicates appear, check for conflicting relationship entries
- Use the delete function to remove incorrect relationships