Related Posts problem

Hi community!

I have an interesting task, but I’m a beginner and don’t know how to implement it. Can you help me?

There are two different types of posts in my project, objects type:objects (for example, a stadium) and photo reports type:reports (about how these objects are built and they are made and added to the site periodically).

When I add a new photo report, I attach it to the object (stadium) using the ACF field. After that, in the photo report data, I have a related post field (id).

image

This gives me the opportunity to display a block with information about the object to which it is attached on the reportage page.

But the problem is that in the object (stadium) itself, of course, it is not fixed in any way that there are photo reports attached to it, and this would give me the opportunity to display all these photo reports on its page.

I think that I need to write some Handler that would take the ID of the related object from the report, find it by ID, and add the ID of the report where this object was taken to its data. And an important point is that there can be many reports. But I don’t know how to write such code…

Maybe I’m completely wrong. Maybe you know how to write code or some other way to implement this functionality?