Skip Navigation

[Resolved] Self-join relationship expected release date

This thread is resolved. Here is a description of the problem and solution.

Problem:
Self-join relationship expected release date

Solution:
self-join relationship are not supported yet with new post relationship and this is something not going to implement very soon. There is no ETA on it.

The workaround is to create a custom select (dropdown) field say "People ID" - and then later use Types hook "wpt_field_options" to fill out the dropdown option for your county dropdown box dynamically.

You can find proposed solution, in this case, with the following reply
https://toolset.com/forums/topic/self-join-relationship-expected-release-date/#post-924486

Relevant Documentation:

This support ticket is created 6 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

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

This topic contains 3 replies, has 2 voices.

Last updated by adamP-2 6 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#924373

I am trying to: join a CPT of 'people' up via a relationship of 'relationship' to the CPT of 'people'.

Eg: CPT of people has in it:

David
Brenda
Julie
Kevin

David and Brenda are married
David and Brenda are parents of Julie
Julie and Kevin are married

Is there a way that I could do something similar using current functionality until the Self-join relationship is reactivated?

Many thanks in advance,
Adam

#924486

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - self-join relationship are not supported yet with new post relationship and this is something not going to implement very soon. There is no ETA on it.

The workaround is to create a custom select (dropdown) field say "People ID" - and then later use Types hook "wpt_field_options" to fill out the dropdown option for your county dropdown box dynamically.

For example:

add_filter( 'wpt_field_options', 'func_dynamic_populate', 10, 3);
function func_dynamic_populate( $options, $title, $type ){
    switch( $title ){
        case 'People ID':
            $options = array();
            $args = array(
                'post_type'        => 'people',    // change post type slug here if needed
                'post_status'      => 'publish');
            $posts_array = get_posts( $args );
            foreach ($posts_array as $post) {
                $options[] = array(
                    '#value' => $post->ID,
                    '#title' => $post->post_title,
                );
            }
            break;
    }
    return $options;
}

Where:
=> You should change 'People ID' to your custom field name. if its not set as 'People ID'.

By this way you can have select dropdown attached to your post where you can select people again and display its value.

#924720

Thanks for that reply Minesh.

#948282

Hello Minesh,
I have used your code above to populate the select drop down field and it works and save great.
However, when I try to add the select dropdown field into a repeatable group it no longer saves the choice. It does populate the select box as I desire, but when I click update my choice isn't retained.
Is there something that needs to be added to the function code to make this work?
Thanks in advance,
Adam