How to use custom taxonomies to reference complex relationships?

I’m working on a site that will in part house information on products that many people have worked on in different roles. I’d like for people, the projects they’ve worked on, and their roles in the projects to be searchable using custom taxonomies. Projects and People are custom post types.

Let’s use a movie as an example. That’s not what the site is for, but the problem is exactly the same:

Read More
  • Alice worked on Big Movie as the director and producer.
  • Bob worked on Big Movie as an actor.
  • Carl worked on Big Movie as the scriptwriter.
  • David worked on Big Movie as another scriptwriter.

I want to be able to search for all directors, search for everyone related to Big Movie, and search for everything Alice worked on (and Bob, and Carl, etc.).

So far I’ve simply skimmed the codex and my thought is to have a hierarchical taxonomy “People” associated with the post type. Every entry will have two levels:

  • Role
    • Name

So the “People” taxonomy of Big Movie might look like this:

  • Producer
    • [Alice’s Person post ID]
  • Director
    • [Alice’s Person post ID]
  • Writer
    • [Carl’s Person post ID]
    • [David’s Person post ID]
  • Actor
    • [Bob’s Person post ID]

Is there a better or more efficient way to associate people posts with their particular roles on particular project posts? Does this approach actually solve the problem and allow for efficient searches for people based on the roles they have played, the roles they have played in particular projects, and the particular projects they have worked on?

Related posts

Leave a Reply

1 comment

  1. Taxonomies are probably not the best option: There is still no table for term meta data, and if you are using a people custom post type plus a taxonomy of the same name, you will have a hard time keeping everything synchronized.

    Install the plugin Posts 2 Posts, register a connection between people and movies:

    function connect_people_movies() 
    {
        p2p_register_connection_type( 
            array(
                'name' => 'people_movies',
                'from' => 'people',
                'to' => 'movies'
        ) 
        );
    }
    add_action( 'p2p_init', 'connect_people_movies' );
    

    See the plugin’s wiki for more instructions and examples.