Skip Navigation

[Resolved] 2-way relationship select?

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.

This topic contains 12 replies, has 3 voices.

Last updated by thomasS-11 5 years, 9 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#267845

Hi.

I made 2 post types.

1) Applications.
2) Products.

I have defined Applications as parrent for Products.

When i add/edit a Product i get a selectlist with All my Applications (as expected and as desired).
But in Applications, i dont get a selectlist with my Products? (this is wiered?)
- I only get the posibility to "Add new" and when i add a new i can only give it a Post title?
(SCREENSHOT ATTACHED)

This is not working as expected at all..
I just want a 2-way relationship like from Product to Application (with selectlist) on both posttypes.

Further more i would really like to know how to display the relations in views content template.
I dont get a field with relationships? How do i display the link for the relationship so when in Application i can show the link to the related Product?

Please reply ASAP as this is really urgent and im behind schedule after using too much time figuring out why its behaving like this, before i finally gave up and turned to supportforum in WP-Types.

#267858

Further more- when in Products (Where the selectlist works as desired) i can only choose 1 parrent? is it possible to use multiple parrents? So that the product can appear in multiple Applications?

#267958

Please, i need support very urgent.. i posted my request more than 24 hours ago, yet i see many other topics gets solved before mine eventhough they was posted later? - At least reply and say you will look into it.

#268030

PLEASE HELP!

#268119

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

1) Q: But in Applications, i dont get a selectlist with my Products? (this is wiered?)
Yes, it is expected result, In Types "field table", you can not setup existed child post in parent post.

2) Q: Further more i would really like to know how to display the relations in views content template.
There is a custom field _wpcf_belongs_[parent_type_slug]_id in the child post, which stores the parent post ID,
Here is a document about
Querying and Displaying Child Posts
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

3)Q: urther more- when in Products (Where the selectlist works as desired) i can only choose 1 parrent? is it possible to use multiple parrents? So that the product can appear in multiple Applications?
In your case, I suggest you setup a many-to-many relationship between post type "Applications" and "Products"
Then you will be able to connect multiple "Applications" posts to multiple "Products" posts
See the document:
Creating and Displaying Many-to-Many Post Relationships
https://toolset.com/documentation/user-guides/many-to-many-post-relationship/

4) sorry, the threads in weekend can be handled in the monday.

#268153

1) But that doesnt make sense what so ever.. why would you do that? How do i do if i want to achieve the desired result? to have a simple 2 way relationship between 2 post types?

2) I didn't notice so, but i will check it out.

3) Im not sure you understand this question, i mean i want to have 2 Application's related to 1 product.. Choosing more than 1 parent type in this situation is not what im looking for.. im not looking for 2 post types as parents, but 1 post type.. i want 2 posts from 1 post type to be the parrent.

Maybe this isn't much like Drupal views at all..

#268346

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

1) it is not possible with Types,
3) one child can have only one parent, so one product post can be related only one parent Application post, and as I suggest above, you will need try setup many-to-many relationship between post type "Applications" and "Products"

#268405

you should really consider implementing this in the future.

What if i.e. a football player (Child) is playing for more than 1 football teams (Parents), then you can't make a multiple connection between them, and that is really sad i think. That is one function that most big structured websites would need.
It really dont make sense that you can have multiple childs, but not multiple parrents! we need inter-linking in Views really bad. Please check Post2posts plugin as its exactly what Views needs.

About your suggest, you dont understand my needs i see.. like i said that i can't use that for anything.. How do you setup "Many to many" when there is only 2 posttypes? it doesnt make sense.. many to many is for if you need to connect "products" to both applications and (i.e.) books? you dont set many-to-many relation if its only between 2 post types.. that doesnt make sense at all..

#268433

I struggled with the same problem yesterday. The many-to-many relationship works very well for this. It took me a while to get my head around it, but effectively your intermediate post type acts as would a join table in a database. Although it seems illogical, it is an elegant solution once the relationships method sinks in.

https://toolset.com/documentation/user-guides/many-to-many-post-relationship/

#268679

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Q: football player (Child) is playing for more than 1 football teams (Parents)
This case is fit for many-to-many relationships. and I don't think there is other solutions within Types.

Q: How do you setup "Many to many" when there is only 2 posttypes?
To setup "Many to many" relationships, you will need create an Intermediary post type, see our document:
https://toolset.com/documentation/user-guides/many-to-many-post-relationship/

#268708

OK so i have 2 ONLY post types. 1 is Football team, 2 is Players

I can only add 1 Football team to 1 player when i have set it up to be child parent?
Im starting to feel a little stupid here to be honest, i think this is very confusing and im not new to this.

What are the 3rd content type for? it makes no sense to me?

Like i said before and is in my screenshots, i can ONLY ADD 1 Parent for each child!

Can you upload some videotutorials on Youtube or something?

#268956

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Here is a test site for you:
1) Create post type "Football team":
hidden link
user/pass: xgren/111111

2) Create post type "Players":
hidden link

3) create the Intermediary post type:
In section "Post Relationship", set both above post types "Football team" and "Players" as it's parent:
hidden link

So when you edit a player post:
you will be able to connect it with multiple team posts:
hidden link

And when you edit a team post:
you will be able to connect it with multiple player posts:
hidden link

#269084

i have tried doing as explained above, and i really think this solution is ilogical.. i dont think this makes sense for connecting 2 post types at all.. you now need 3 post types to connect 2.. i really dont understand this logic..

I will just go with Posts2Posts plugin and modify some PHP because if this drives ME insane, then it will KILL the client that i am going to deliver the website for..

That being said, i really think you should consider a more simple way to connect 2 post types and crosslink between them like Posts2Posts (please try the plugin so you know what i mean). This seems more like a temporary solution if i may say so. i LOVE WP-Views, but things like this makes me reconsider if i should use WP at all..