Skip Navigation

[Resolved] post relationships connected by "id" (custom field) – not by title

This support ticket is created 3 years, 11 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by Jamal 3 years, 11 months ago.

Assisted by: Jamal.

Author
Posts
#1943261

i want to connect posts. so i am using the relationship feature. one post type is "team" and one post type is "member" and i want to connect the teams using an ID (custom field) of the member. not with the title of the member. how can i do that? And at the end i just want to add the ID to the team (just putting the ID in a field) without clicking "connect existing member). Is that possible?

#1944119

Hello and thank you for contacting the Toolset support.

I believe it is possible with some custom code. The trick is to use a select field and populate its possible values using custom code. Check this similar ticket https://toolset.com/forums/topic/add-select-field-to-users-from-a-custom-post-data/

I hope this helps. Let me know if you have any questions.

#1948783

thanks. but where do i put this code?

#1948879

It can be added on the theme's file, a separate plugin, or a snippet in Toolset->Settings->Custom code. These articles explain it better:
-https://toolset.com/documentation/adding-custom-code/
- https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

#1948967

it's not working and i am not sure if its the feature i need.
will explain a bit better.
That's how it is: hidden link
That's how it should be: hidden link
The member of a platform should be connected via ID and i should be able to just put the ID to the custom field and then it should be connected. I want to that to use the WP API to just put the ids in this field.
Because "connect to existing members" i can't do with the API
And the connection should be the ID because name could change

#1949243

The custom code that I shared in my first reply will allow you to have a dropdown to select members from it and save the ID on the field. This is useful to reduce the possible typing errors.

Now, I understand, that you want to enter the multiple member IDs in a field, without having to choose from a list of members. In that case, I'll suggest using a Number field and making it accept multiple values. Check this screenshot hidden link
But, in this case, the results will be similar to hidden link

You said, that you want to use the WP API, are you talking about WP REST API?
If yes, please read the following articles to know more about REST API support in Toolset:
- https://toolset.com/documentation/programmer-reference/toolset-integration-with-the-rest-api/
- https://toolset.com/documentation/programmer-reference/types-api-filters/

Please note, that the Toolset relationship API offers some functions that you may use in a custom REST Controller to connect posts in a Toolset relationship. https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

If you believe that I still do not understand your question, please provide more details about what you would like to implement. Because I am afraid to suggest something that will become irrelevant in the future when you would like to implement complex searches or other features.