Hi! I have two Types on my site: Creators and Shows.
The same Creator can have multiple different jobs on a given Show (Director, Writer, Actor), so I can't make different post types for each different job. Instead, I'm creating multiple Many-to-Many Relationships betweeen Creators-Shows for each different job they can have.
How do I build a Content Template to display these different relationships? Should be rather straightforward, but I'm getting lost because it's a bit more complex than the Toolset video course. I don't understand what Intermediary Posts do, exactly.
Attached is an image from IMDb of what I want to accomplish.
There is a limitation currently with Toolset relationships which means you cannot have multiple connections between the same posts that is a problem here.
If I were connecting Creators to Shows, I would store the role of the creator on a given show in a relationship custom field. (The purpose of an intermediate post type is a place to store such custom fields, because they don't belong on either of the main post types.)
So, take the recent Spiderman films.
Stan Lee has a writing credit, but also has an acting credit.
So ideally you would make one connection between Spiderman and Stan Lee where the relationship field for credit is "Writer", then you would make a second connection between Spiderman and Stan Lee where the credit field is "Actor".
Then you can use a View to return all of the Creators who had an Acting credit on Spiderman, and another View to return all of the Creators who had a Writing credit on Spiderman, etc.
But right now Toolset doesn't let you make multiple connections between the same posts, so a single relationship with a credit custom field won't work here.
Instead you need a separate relationship for every kind of credit, so join Creators and Show in a "Writers" relationship, and join Creators and Show in an "Actor" relationship, etc. for every kind of credit.
Then in the template for a Show, you can display its Actors simply enough by adding a View of Creators with a relationship filter for the Actor relationship. And you create another View for the Writer relationship, and as many Views as you need for each relationship for each kind of credit.
Hi Nigel, thanks so much for the fast reply! I'm getting closer to my goal.
1. Can I add a "relationship filter" in the blocks editor? I found the filter once I created a view in the legacy editor, but that's much less intuitive to use and I'd prefer not to.
2. I'm also having trouble displaying and querying custom fields. My views aren't displaying them via shortcode, and in queries it claims there aren't any posts, when there definitely are (published ones, not drafts!).
[EDIT for #2] Concretely: I'm (1) trying to display a custom string after the name of my credit (Head Writer, Co-Writer etc) and (2) trying to sort my credits by a priority number I defined as a custom field, but when I try to set that as the order, it says there aren't any posts.
1. Can I add a "relationship filter" in the blocks editor? I found the filter once I created a view in the legacy editor, but that's much less intuitive to use and I'd prefer not to.
Yes you can add a relationship filter using the block editor. See Screenshot
2. I'm also having trouble displaying and querying custom fields. My views aren't displaying them via shortcode, and in queries it claims there aren't any posts, when there definitely are (published ones, not drafts!).
I would need to check the site to see what is happening here. Can you allow me to have admin access to the site as well as a link to the page where the view is so that I can have a look.
1. I wasn't looking for a dynamic filter, just to be able to edit the Query Filter for the view. That doesn't seem to be editable in Gutenberg, right? But I've gotten used to the classic editor so that's solved for now.
It is still possible to add a static relationship filter with blocks. To do it you will need to select the view in the block navigator in the top left hand corner. Then on the blocks tab in the right hand side you will need to scroll to the query filter section and add your query filter from there.
2. Regarding the sorting issue. I've found the problem. The field that you are sorting for is the on the intermediary post type.
The first thing you will need to do is to enable "publicly queryable " so that you can create a view for this. hidden link
So you will need to create another layer of the view, so you will need to create the intermediary post type view and then add your Post relationship filter to the intermediary view and then add your current child view inside your intermediary view <wpv-loop>
Finally just add the sorting to the intermediary post view and it should sort the current child view correctly.
For the current child view as well you will need to set the current query filter to "The current post in the loop".
Please let me know if this resolves the issue now.
thank you, and sorry for the late response. I tried implementing your suggestion, but it's a few steps beyond my current understanding of Toolset. Could you please point me to the right course lessons to understand intermediary post type views and child views? I can't seem to find the right tutorial.
There isn't a documentation that can guide you specifically on this. To be able to do this require's knowledge of what you can actually do in toolset. Our Documentation won't show everything that is possible. It will discuss the basics to get you started.
For e.g intermediary posts are mentioned in this document below but it doesn't mention that it can be used in a view etc.
thanks for the link. As soon as I choose "Creators that are related to the current Show", I get a Query Filter that I can't edit – but it's choosing the wrong relationship for me (img. 1). I have several Many-to-Many-Relationships going on, so I need the edit option.
If I pick "All Creators" and set a filter manually for the relationship I need, I can no longer choose an intermediary post as my post source (img. 2), and therefore can't display and relationship custom fields...
Thank you for your help, Shane! I was able to solve my problem with the links you provided and the info that it wasn't possible in Blocks. I worked it out in the classic editor.