I have such a structure.
1. Fights (parent)
2. Fighters (child)
3. Relationship fights-fighters (many to many)
The post type "Fight" has a select field "method" (with values: knockout, submission, judging ...).
My question (I want to make sure that today it is impossible).
When I ask for an intermediate post type "fights-fighters", can I query the "method" field of the related fight?
Now I solved the problem by moving the "method" field to an intermediate post type "fights-fighters". But it's wrong to duplicate the data ... Now you need to fill in method for each fighter, but you want to do it once - for "Fight".
Here is what I managed to find on this topic:
https://toolset.com/forums/topic/how-to-use-repeatable-field-as-filter/
I'm going to import a lot of data, so I want to do everything right. Can I leave the "method" field in the post type "Fights" with the hope that soon the query filter for the fields of the related posts will be available?
In the future I want to display data about the fighter "the number of wins by knockout" for example and so on ..
Thank you
Hello,
I assume you are going to setup a view to query the "fights-fighters" posts. and filter by custom field "method" of other post type "Fight".
If it is, the answer is no, there isn't such a built-in feature within Views plugin, and I don't think this feature will be available soon, and there isn't ETA for it.
As a workaround, when you query the "fights-fighters" posts, in the Views loop you can get he related "Fight" post information and it's custom field "method" field value
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/
Use it in the wpv-conditional shortcode, check if the custom field value is the specific value, and display the item in view's loop.
More help:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
Hi Luo
Yes you are right. At this stage I decided to avoid this problem.
Thank you.
Let's return to the related posts.
https://toolset.com/forums/topic/sorting-child-output-by-parent-field/#post-617735
Nigel said that with the help of the new m-m relationship it will become possible to sort and query related posts. Can you say (roughly) when this will be done?
I am not sure when will it be done, but there is a plan to implement it, I guess it might be months.
Thanks I got it.
Will these queries from related posts to the database be slower? Will this be an additional layer of queries?
No, it should not produce the performance problem, but you can still feedback if there is any problem. Please create new thread for the new question, that will help other users to find the answers.