[Resolved] many-to-many relationship : filter and the sorting
This thread is resolved. Here is a description of the problem and solution.
Problem:
How to filter by fields of related posts?
Solution:
It is currently not possible, but is a feature that will become possible after the update to Types 3.0 and related Toolset plugin updates. It won't make the cut for the initial release, but is one of the first features that will be added thereafter.
This support ticket is created 6 years, 9 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.
Our next available supporter will start replying to tickets in about 0.14 hours from now. Thank you for your understanding.
The current implementation of post relationships typically involves using a View that queries the intermediate post type to be able to display related content.
The problem then becomes that you can only filter (or sort) something by properties of the thing itself, i.e. you can sort or filter intermediate posts by fields of intermediate posts, not by fields of the parent posts.
I have used this analogy before to explain, which may make sense:
With a playground of children you might tell all the children wearing hats to stand on the left, simple enough.
Your request sounds more like telling all the children whose parents have a combined income over €100k to stand on the left. But you don't know what the income of the parents of the children is, and guessing from the labels on their coats doesn't count.
This would work if the children came to school with a badge showing their parents' income.
In terms of querying the database that would be akin to custom table joins with SQL, and goes beyond the querying possible natively with WP_Query (and, therefore, Views).
Now, post relationships are being significantly overhauled (new betas will be published imminently) and will make this possible, to filter and sort by fields of the parents.
There will be new documentation published to describe the changes, too.
I suggest you wait a day or two and then familiarise yourself with what is involved with the new system and adopt that for any new project.