[wp-hackers] Advice regarding Custom Post Types and Taxonomies

Mike Walsh mpwalsh8 at gmail.com
Thu Aug 9 23:16:16 UTC 2012


On Thu, Aug 9, 2012 at 5:30 PM, Otto <otto at ottodestruct.com> wrote:

> On Thu, Aug 9, 2012 at 12:18 PM, Mike Walsh <mpwalsh8 at gmail.com> wrote:
>
> [ snipped ]

>
> I think the real question is why would a "team" be a post type? A team
> is essentially a group of players, wouldn't it make more sense as a
> taxonomy?
>
> If you need to define a post type for the team in order to have stuff
> about that team in the posts-table (totally understandable), then I'd
> associate the team-post to the team-taxonomy in an implicit manner,
> perhaps by sharing the postname and the term-slug. Essentially, the
> players and the team would both have the same terms in the
> team-taxonomy.
>
>

This exact question is exactly what I am trying to ascertain.  In our
situation, which I suspect is pretty typical, a team is more than a group
of players which is why in my current implementation I defined the roster
(which is absolutely a group of players) as a taxonomy and a team, which
has information (e.g. a coach, a manager, a treasurer, a mailing address, a
contact email, etc.) as  custom post type.

Where I am struggling, and right now I am leaning toward Posts2Posts, to
connect players to teams, is how to connect everything together.

Right now I have my Roster as a custom taxonomy and have created two terms
- "2011-2012" and "2012-2013".  I can go through the players and assign
them to the rosters they are part of.  Everything works great until I add a
second team and this is where I am stuck.

Here is a scenario:  Player 1 is a member of Team A for 2011-2012 and
member of Team B for 2012-2013.  Player 2 is a member of Team B for both
2011-2012 and 2012-2013  Player 3 is only a member of Team A for 2012-2013.
 Both Team A and Team B had rosters for 2011-2012 and 2012-2013.

I am not sure how I could uniquely identify the roster for Team A for
2011-2012.  I would need to connect a player to a specific team roster
which is why I started thinking that a hierarchical CPT might be a solution.

Why would I have more than one team?  Imagine a scenario where a club
fields multiple teams in an age group.  They may choose to play in two
different leagues with some overlap between rosters.  A pool of players can
be assembled into multiple rosters depending on the need.


Does what I am trying to do make sense?  Maybe I should draw a picture of
the relationship i am trying to construct.


-- 
Mike Walsh - mpwalsh8 at gmail.com


More information about the wp-hackers mailing list