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?
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.
thanks. but where do i put this code?
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/
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
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.