Hi. I'm opening up this "mess" to see if we can get it to work! I'ved worked with Beda on this ticket:
[Closed] Displaying Custom Fields in Search Results in a Many to Many setup opened on July 18, 2017
I've built a query page for my client (hidden link) where we want to see a list of machines (custom post types) filtered by the content in custom fields. As you can see in the attached screen shot in PM1.png, all the data shows except the company name and the ownership type. In screenshot PM2.png, you can see the Loop code in the view. i've made changes and redone it so many times but it still isn't working.
This is a many to many relationship. Companies are parents. Contacts are children. Ownership are children. Products (machine) are parents. Ownership are children of the Machines. Each machine is owned by a company, hence the query.
From your question it looks like your many-to-many relationship looks like this:
Companies Machines
\ /
\ /
Ownership
Your View is querying and displaying Machines.
You want to output content about the linked Company.
Your problem is that the information about post relationships is stored on the child, so the linking Ownership post knows which Company owns which Machine, but the Machine knows nothing about the relationship and the Company knows nothing about the relationship. You can go up to grab fields from the parents, not down to get them from the child.
The solution here is that you need to add a nested View where you want to output the company info.
So you create a View which returns Ownership posts that has a post relationship filter to show ownership posts that are children of the current machine. Then in the Loop Output section of this View, that is where you can use the id attribute to output fields not from the ownership post but from the parent Company.
You then insert that View in the Loop Output section of your original View where you want the company field to appear.