I have a website in which I have created several types of custom posts.
On the one hand I have teams and on the other players.
I have created a one-to-many relationship
Now when I show a player's post, I want to show related players, but from the same team. I think I have tried all possible ways, but I can't, beyond showing other players in general, but not from the same team. What I need is that somehow, the system detects which team belongs that player that is being shown and shows other players of the same team to which it belongs.
Something escapes me, but I don't know what it is. Can you help me?
I don't use the new method through blocks, because I don't use them. I need the solution for the usual system.
Thank you for contacting us and I'd be happy to assist.
To achieve this you can follow these steps:
1. You'll create a new post view, for example, "View to show related Players from the same Team" and set it to show the "Players" posts.
2. In the view's settings, check the option "Don't include the current page in query result" so that the current player is not included in the results and also add a post-relationship filter, linked to a shortcode attribute "wpvrelatedto", as shown in the attached screenshot.
This view will allow you to show all players, related to a specific team whose ID has been passed through the view's shortcode attribute.
Hello Waqar. Well, this was the only option that I didn't try, because I don't quite understand it in the manuals. But it has already become perfectly clear to me and it opens up many new possibilities for me. It is a very powerful solution.
It worked perfectly and I have fixed the problem.
You have been a great help and I appreciate your time and the solution you have given me.