Home Forums Backend Issues (wp-admin) Relationship field struggles


Relationship field struggles

  • Im currently working on this project which regards Teams and Players. For the project I have created two CPT’s called Teams and Players.

    The idea is to create a ton of players in the backend and create a handful of teams and have teams players linked to teams with the relationship field. Now I’m running into some issues, which I cannot seem to figure out. I will describe them below:

    I want to create the possibility to only add a Player to a single team.
    If a team is already assigned, then it should not be able to go into another team and assign this very same player. So if possible I need to disable moving player X into team B, if player X is already assigned to team B.
    My current construction for this is a relationship field which is added to the Teams CPT with field name teams_players

    On the player overview page, I want to display the team which the player is assigned to
    On the player overview page Im loading all players as a card by wp_query. Now I want to somehow display the post title of the team which has this player assigned (relationship field is: teams_players and is added to the Teams CPT).

    On the player single page, I also want to display the post title of the team which has the player assigned.
    This one is very similar to the previous case. But instead of displaying it on an overview page where the players are loaded by wp_query, this is regarding the single page of the player post type. Which I think will a different code.

    I hope I have made my struggles clear enough to understand. Hope somebody is able to help me out with this one.

    Thanks in advance 🙂

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.