Skip Navigation

[Resolved] Creating Custom Field that Connects Checkbox & Related Fields

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

Problem:

How to setup a school-teacher website:

- one teacher can connect with multiple school posts

- one school can have only one location.

Solution:

You can try these:

https://toolset.com/forums/topic/creating-custom-field-that-connects-checkbox-related-fields/#post-2365679

Relevant Documentation:

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

This topic contains 6 replies, has 2 voices.

Last updated by simchaH 1 year, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#2365447

Hello,

I have an interesting question. I already uploaded all info to my database, so I would obviously prefer to not have to re-upload everything all over again. That being said, I am open to any ideas/options to come up with a possible solution:

I have a multi-checkbox selection part of a group of custom fields. These checkboxes directly relate to connected posts, and in order to explain my question, I will give a real world example:

CPT A is School. Inside the post will be location, name of School, phone number etc.
CPT B is a teacher at the School. Inside the post will be the teachers name, phone, email - and a multi-checkbox field with options of the different classes possible for teaching, I.E. Math, Science, Literature etc..

My question is, is there any feasible way to directly connect and display to the admin in the backend, that the teacher "gives" Math at a particular School they are connected to? Since it is set up as a many to many relationship, 1 teacher can be a Science teacher at one School Location, and also be a Math teacher in another location, so I want to have this information separated and discernible for myself. This way, instead of just seeing a bunch of checked off checkboxes inside the teachers post, I will see and know which class they give in which location.

Thanks,
Sim

#2365679

Hello,

I assume we are talking about these:
one teacher can connect with multiple school posts
one school can have only one location.

In my opinion, you can try these:
1) Setup two post types:
- Teacher
- School (with custom field "Location")

2) Setup many-to-may relationship between above post types "Teacher" and "School", enable intermediate post type, an add a custom field "Class" into the intermediate post type

When you edit a Teacher post, you will be able to connect it with other School posts, and setup the field "Class" values.

More help:
https://toolset.com/course-lesson/many-to-many-post-relationships/

#2366145

Thanks for the quick reply Luo,

So if I would like to implement this, is there any way to do this and just change the settings in Toolset? Or will I have to re-upload all the posts with all the relations all over again? I used WP Importers Pro and uploaded multiple spreadsheets.

The way I currently have it is the way you described with many teachers being able to teach at many schools, but each school is only listed once and is unique to its location. Is there a way to simply add the intermediate post type relationship and somehow "port over" the multi-checkbox as the related field in the intermediate post? Or will that break the DB in any sort of way

Thanks,
Sim

#2366427

You can follow our document to setup/import csv file using "WP Ultimate CSV Importer Pro", which supports Toolset many-to-many relationship.
https://toolset.com/course-lesson/how-to-import-posts-from-csv-files-and-maintain-relationships-when-using-the-csv-importer-plugin/

With Toolset many-to-many relationship, you can connect one specific "teachers" post and another specific "school" post only once, so it is "each school is only listed once and is unique to its location".
And in single "teachers" post, you can display related "school" posts by following our document:
https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items

There isn't such kind of built-in feature to "port over" the multi-checkbox as the related field within Toolset plugins.

#2366471

Okay, so you recommend I should delete all my (thousands of) posts across 3 custom post types, and delete the relationships, and start over from scratch and this time create a new intermediate post type, and then re-upload all my posts once more using the importer plugin?

I just want to make sure I'm not missing something and there isn't a possibly quicker and easier way to implement this? The way it seems from your previous message, it does sound like I will need to start over.

Thanks

#2366477

I suggest you setup a new test site, setup as I mentioned above, check if it is what you want, then start over in the live website.

#2369689

My issue is resolved now. Thank you!

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