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

Ben Lobaugh lists at lobaugh.net
Thu Aug 9 17:57:55 UTC 2012


Hi Mike,

You may want to check out the Posts 2 Posts plugin. It has the sort of 
functionality you are looking for. You may also be able to look at the 
plugin code and pull out the parts you need into your own and not 
require the additional plugin in your WP install

Cheers,
Ben

On 8/9/12 10:18 AM, Mike Walsh wrote:
> I am working on a new site for my daughter's soccer team and have decided
> to use it as an opportunity to learn more about Custom Post Types and
> Taxonomies.  I have the basics working - I have defined a post type for
> players and another post type for teams and each have a number of custom
> fields based on what the team wants to track for each player and at the
> team level.  I have also defined a taxonomy for player positions so the
> players can be looked at by position.  I am struggling with how to define a
> roster for a team and connect the player CPTs to the team and/or roster.
>   Should the roster be a taxonomy or should the team CPT be hierarchical and
> each roster is a child of the parent team?
>
> My initial solution was to define the roster as a taxonomy as it makes it
> very easy to assign each player to a roster (e.g. Fall 2012, Spring 2013,
> Indoor 2012-2013, etc.).  But doing so doesn't really connect the players
> to the team - for that I need to use a plugin like "Posts 2 Posts" or
> reinvent the wheel which I'd rather not do.  So if I connect the posts,
> does it make more sense to define the roster as part of a hierarchical team
> CPT?
>
> Right now I am doing this by trial and error as I learn more about post
> types but with their first game a week away, I need to finalize my
> solution.  I am hoping the collective genius of wp-Hackers has some
> recommendations or can point me toward something similar that I can learn
> from.
>
> Ideally I'd like to end up with the ability to look back in time to any
> roster which is defined to see which players were on the team at that time.
>   There is a small chance that the site could grow to support more than one
> team so I'd need to be able to differentiate the players who were on the
> Fall 2012 roster of Team A versus the players on the Fall 2012 roster of
> Team B.  I think a hierarchical post type would help me do this but I am
> not sure if this is the best solution.
>
> Thanks,
>
> Mike



More information about the wp-hackers mailing list