Skip Navigation

[Resolved] How to create from/to relationships? Possible to do within the same post type?

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

Problem:

I'm just getting started, nothing to show. Trying to lay out my data structure and determine best ways to implement, and I have a challenge to solve.

At the heart of my structure are custom post types called States. What I am struggling with is how to show simple from/to relationships between States, so that on a State post, I can easily display related states, designating some as "from" and others as "to." I've attached an rough image showing what I mean.

One possible challenge to this is that I expect to post dozens if not hundreds of States, and some will have the same name. I need to be able to easily link from one State to the correct from/to State when entering the data.

Is this possible in Toolset?

Solution:

I don't think it is possible within only one post type, within only one post type, there is only a "hierarchical" option
https://codex.wordpress.org/Function_Reference/register_post_type#hierarchical

And Toolset post type relationships are based on different post types:
https://toolset.com/documentation/post-relationships/

In my opinion, you can try these:
1) Create two post types:
- States
- Transforms

2) Create two one-to-one relationships between "States" and "Transforms"
- States transforms from
- States transforms to
https://toolset.com/documentation/post-relationships/

Then you will be able to connect "States" posts with each other

In a single "State" post, you can get the related "Transform" post on different relationships, and display the related "State" post

Relevant Documentation:

https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/

This support ticket is created 5 years, 7 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by Luo Yang 5 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#1110803
Data Structure.png

Hello, I'm just getting started, nothing to show. Trying to lay out my data structure and determine best ways to implement, and I have a challenge to solve.

At the heart of my structure are custom post types called States. What I am struggling with is how to show simple from/to relationships between States, so that on a State post, I can easily display related states, designating some as "from" and others as "to." I've attached an rough image showing what I mean.

One possible challenge to this is that I expect to post dozens if not hundreds of States, and some will have the same name. I need to be able to easily link from one State to the correct from/to State when entering the data.

Is this possible in Toolset?

I've seen that Metabox Relationships seems to enable this, and wonder if it's possible to use this plugin alongside Toolbox. I'm not an experienced coder though, so I'm hoping for a solution within Toolbox.

Thanks for any insight or assistance you can offer.

(In case it's relevant, I am using Elementor with Toolset to build my templates.)

#1111346

Hello,

I don't think it is possible within only one post type, within only one post type, there is only a "hierarchical" option
https://codex.wordpress.org/Function_Reference/register_post_type#hierarchical

And Toolset post type relationships are based on different post types:
https://toolset.com/documentation/post-relationships/

In my opinion, you can try these:
1) Create two post types:
- States
- Transforms

2) Create two one-to-one relationships between "States" and "Transforms"
- States transforms from
- States transforms to
https://toolset.com/documentation/post-relationships/

Then you will be able to connect "States" posts with each other

In a single "State" post, you can get the related "Transform" post on different relationships, and display the related "State" post
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/

#1111754
Data Structure v2.png

Hi,

Thank you for your suggestion. I had found this article (https://toolset.com/faq/how-do-i-associate-one-child-with-several-parents-of-the-same-type/) and was trying out an intermediary custom type, but your explanation enabled me to simplify things a step further. I've attached a new map of the structure I'll try implementing now. Please let me know if you see anything that could give me problems.

I'd like to keep this ticket open for the moment, until I can get things working. I anticipate needing to ask for advice on setting up Views to display the information properly.

Thanks again for your help.

#1112041

I can not find anything wrong in your new map of the structure, please update this thread if you still need assistance for it, create new thread if there is other new questions. thanks

#1112066

Thank you! I appreciate your help.

Perhaps it makes sense for me to just open a new ticket if I run into any issues with Views, rather than leave this one open. What do you guys prefer, and what is the best way for me to get an answer more promptly?

#1112101

As I mentioned above, we prefer one ticket one question, that will help other users to find the answers.

#1112105

OK, thanks so much.

#1112536

You are welcome

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.