Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

  • 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.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

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

share|improve this answer
add comment

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.
share|improve this answer
    
I'd like to store the team as a CPT in order to make use of the CPT interface, adding things like featured image, and a number of meta boxes and custom fields that describe the team. I cannot do this if I set team as a category. For competitions I also need to add some information, and an image. –  drtanz Aug 9 '12 at 10:42
    
Hey, check the updated, that'll surely help you. –  amit Aug 9 '12 at 10:54
    
I've considered that option, however I'm building a plugin, and therefore cannot make use of another plugin. All functionality should be within my plugin. –  drtanz Aug 9 '12 at 14:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.