One of the nifty features of Toolset is its ability to visually create and manage post relationships. To some extent my question is a little strange because it involves bypassing that wonderful interface.
I am developing a course catalog for a college and have two custom post types: Course and Section. A Section is an instance of a Course.
Using "the Toolset way," I'd need to add a new Section post and in the backend click "Connect existing Course." This is very tedious if I have 100+ sections and need to associate Sections with Courses 4 times a year. Barf! So, my question: if both Sections and Courses have a field in common—let's call it course number—is there a way to set a view to display a list of courses where the Course's Course Number is the same as the Section's Course Number?
If this were a relational database and I could query it via SQL, the query would look like...
select courses.course_name from courses, sections where course.course_number = section.course_number;
Another way of asking this question is, is there an automatic way to create post relationships—for example, if I were importing Sections via a CSV file with a plugin like Ultimate CSV Importer Pro? I'm trying to reduce the administrative burden on the people who will be doing the data entry.
Saul
PS. I've been corresponding with Nigel about my project for over a week. Can this support ticket be assigned to him?
"is there a way to set a view to display a list of courses where the Course's Course Number is the same as the Section's Course Number"
You could display sections that have the same course number field value as the "current" course, or vice versa.
If you are comparing something, you have to have something to compare it to, right?
So you could create a View to display courses, add a Query Filter for the course-number field where the value comes from a shortcode attribute (e.g. "coursefield").
Then when you insert the View in, say, a template to display a section (because we need something to compare to), you populate the coursefield shortcode attribute with the value of the course-number field, something like
What you're suggesting makes sense. Regarding the issue of whether I'm concerned about connecting posts on the back end, the gist of my question was about trying to find a way to avoid associating posts on the back end, so your proposed solution is totally appropriate. But I've realized that even if an archive page can display a list of sections, I still need to access the parent post's custom fields, and the easiest way to do that is by associating the posts via the post relationship field in the back end. Otherwise I think I'd have to create custom PHP function(s) to look up the course details for a given section's course number. Blech. Omitting the post relationship in the back end would also make the connection to the parent course pretty opaque; with the Toolset post relationship field, a user can see, and modify, a course on the section edit page in the WP back end.
I'm still going to try to think about a way to prevent a user from having to manually associate 100+ sections with corresponding courses four times a year. It just seems very tedious.