Home Forums General Issues How would you structure this?


How would you structure this?

  • Alright, I’m still new to ACF so trying to understand bidirectional relationships and such.

    I’m going to use a simple example with super bare boned data but how would you structure this?

    Hockey season
    Player name

    Hockey season would need to show years maybe all the players who played that year and how many total goals per year

    Players would show basic info then seasons played and goals each season.

    This is how I think, but correct me if I’m wrong

    CPT Seasons
    ACF Season
    — year
    – players (relationship list)
    – goals each player (relationship)

    CPT Players
    ACF Player
    — Name
    – Seasons (repeater)
    —- Season (relationship)
    —- goals (relationship)

    And if I’m correct, how would I go about showing a league leaders on the season page

    Player – 45
    Player2 – 34
    Player3 – 24

    I don’t really know how to call the player subfield from the seasons page. Suggestions?

    (And if my structure is bad just let me know too)


  • You have several problems.

    First off, you are going to find it extremely difficult, if not impossible, to have a bidirectional relationship inside a repeater.

    You are also going to find in extremely difficult, if not impossible, to short players by a value in a sub field (Goals) of a repeater.

    In addition to those it is impossible to relate 2 sub fields to each other and to matching fields of a relationship.
    Player <=> Season
    Player <=> Season <=> Goals
    You are talking about relating one meta field with another meta field. There is nothing in WP that will allow you to related meta fields to each other.

    The only way that I can think of to get these relationships working is
    CPT => Season
    CPT => Player
    In addition to this you need something in them middle of these “Season-Player” or “Player-Season” This cold be done with another CPT or it could be done with by setting one of the other two post types as a hierarchical post type and using child post to link them up. For example child posts for each player that represents each season. I don’t know which would be better, but this would give you the relationships you’d need. “Player-Season” would hold just the goals for a season for just one player.

    Player <=> Player-Season <=> Season

    This is as far as I can think this out here. I can’t see all the details.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.