How to organise this data within WordPress

I have a dilemma in how the data in this scenario should be organised, as well as queried.

The main elements in the scenario are the following:

Read More
  • Competition
  • Team
  • Player

Each player plays for one particular team.

Each team participates in one or more competitions.

First I’d like to know how this data should be stored within WordPress, using Custom Post Types, Taxonomies, or maybe custom tables?

Next comes querying. Let’s say I want to display all players who play in the |Eurocup| competition, and I also want next to each player displayed, his team name and info about team.

Finally, the whole system should prevent redundancy of data. That is, if for example I remove a team from one of the competitions, the players within the team should be automatically disassociated from that competition. Same if the team description changes, the player list should also display the updated team description.

Maybe there is a simple solution to this data storage and relationship in WordPress and I’m missing it, so I’d really appreciate some tips on how to implement this.

Related posts

Leave a Reply

2 comments

  1. Another perspective.

    Instead of using the two custom-post-type ‘team’ and ‘player’. You can use them as a single custom-post-type ‘participant’.

    Participant itself is a hierarchical post type, teams as the first level and player as it’s child. That way there wouldn’t be a player with more than 1 teams.

    If you are doing your own theme, you can make a conditional, checking if($post->post_parent)

    The custom-post-type can be assigned to a ‘competition’ taxonomy, preferably not hierarchical.

    Hope this help

  2. After short overview I think you should treat your blog posts as player profiles. Category as team and tags as competitions, Here are my thoughts –

    Blog posts –

    This will be a players profile page, you can assign categories and tags to it. Category will be his team and tags will be competitions.

    The Category archive –

    When you visit category archive it’ll list all players who’ve assigned that category. It’ll surely work as team profile. With custom templates and WordPress conditional checks you can design it to show related info.

    The tags archive –

    When you’ll visit the tags archive, it will list all the players appeared for that competition.

    Note – If we could link between categories and tags, then we can list out teams appeared in some competitions.

    Update –

    However, there are more efficient methods than this. Such as creating Three different custom post types – player profile, Team profile, Event etc and link betweent them using scribu’s wonderful plugin

    • Posts to posts – Efficient many-to-many connections between posts, pages, custom post types, users.