Hi Tobias,
First sorry about the delay in reply, as we had an unusually high number of tickets in the queue.
Your observation is correct and currently, Toolset doesn't support relationships between the same post types. You're welcome to submit this as a feature request at:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
For now, you can use the following approach as a workaround:
1. The steps that you mention in point "c" should work just fine for storing information about an actor profile with respect to a single-family and this will also let you perform a front-end search to show all actors belonging to a particular family.
2. To establish relationships between two actors, you can dynamically populate options of a "select" type custom field, from the available actor profile posts, using the "wpt_field_options" filter:
https://toolset.com/documentation/programmer-reference/types-api-filters/#wpt_field_options
Note: This approach won't be useful for performing front-end searches, but would still allow you to display relationships at an individual actor profile's level.
For example, you can add a new repeating field group "Actor Relationships" for your "Actor Profiles" post type and include two "select" type custom fields, as shown in the attached screenshot:
- Relationship: will hold information about what is the relationship that we're establishing
- Relationship To: will hold information about which actor profile we're establishing this relationship with
Note that in the screenshot, "Relationship To" field doesn't have any options defined, because we need to populate them dynamically using the "wpt_field_options" filter.
Assuming your post type slug is "actor-profile" and target field's title is "Relationship To", the code will look like this:
add_filter( 'wpt_field_options', function ( $current_options, $title_of_field ) {
if ( $title_of_field != 'Relationship To' ) {
// not our "Relationship To" field
return $current_options;
}
$options = array();
// add first empty value
$options[] = array('#value' => '', '#title' => '--- not set ---');
// get all items from actor-profile posts
$args = array( 'post_type' => 'actor-profile', 'posts_per_page' => -1, 'post_status' => 'publish', 'orderby' => 'title', 'order' => 'ASC' );
$results = get_posts( $args );
if ( $results ) {
foreach ( $results as $post ) {
$options[] = array('#value' => $post->ID, '#title' => $post->post_title);
}
}
return $options;
}, 10, 2 );
This will populate all actor profiles posts as options for this field, using the post titles as the option lable and post ID as the value.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar