If I were doing this, I would have 2 custom content types: teams, and people. The “team” type would use “Relation” custom fields that would let you choose players and refs (i.e. “people” posts).
So if you view John’s page, you need to do a reverse query to see which teams are referencing John in any capacity. In a pseudo-query, you’d have this type of logic: “SELECT teams WHERE player=John OR WHERE ref=John”.
You can do this with WP’s querying functions, but I got so frustrated with their incompleteness, caveats, and lack of consistency that I wrote a separate plugin for this type of scenario: Summarize Posts. It’s going to be part of the CCTM core in the upcoming 0.9.5 version, but for now 0.7 is an independent download.
Using Summarize Posts, you’d want to review this:
http://code.google.com/p/wordpress-summarize-posts/wiki/Examples_get_posts
First you have to get the post_id of John’s page… this is different depending on whether you are inside or outside the loop (groan), but it usually is something like this:
global $post;
$johns_id = $post->ID;
Then you need to use $johns_id in your query. In your single-person.php theme file, you’d put some PHP code like this:
$Q = new GetPostsQuery();
$args = array();
$args['post_type'] = 'team';
$args['meta_key'] = 'player';
$args['meta_value'] = $johns_id;
$results = $Q->get_posts($args);
foreach ($results as $r) {
// iterates over all teams where John is a player
}
$Q = new GetPostsQuery();
$args = array();
$args['post_type'] = 'team';
$args['meta_key'] = 'ref';
$args['meta_value'] = $johns_id;
$results = $Q->get_posts($args);
foreach ($results as $r) {
// iterates over all teams where John is a ref
}
You may want to download the dev version of Summarize Posts, just because I’m in the middle of updating it, and I fixed a couple bugs since 0.7.
Or if you want to check out WP’s options for this, look at WP_Query() or get_posts(), but the basic idea is the same: you need to find the posts that have referenced John’s id in a custom field.