I am building a movie database site and I am wondering in a problem and asking how should I solve this problem.
I have several custom post types movie
, actor
, person
and others. I want to integrate award feature for movies and actors. So I’ll be able to assign awards to a movie. Now, when I am assigning an award to a movie, there are several fields:
- Award Name (e.g: oskar, mtv movie award, etc)
- Year (which year the award was given)
- Category (which category, e.g: Best Actor, Best song etc)
- Receipents (which
actors
,person
(custom post type) won the prize )
So, I should be able to browse to a movie
and see the award info (example). If I go to a particular award
, I should be able to see the awards by year. If I go to a actor
or person
profile, I should be able to see which awards they got in which year.
Now help to structure the custom post type / custom taxonomy assignments. How should I assign the awards?
Have a
nomination
post type.So your awards post type doesn’t represent an award, it represents the ‘nomination’ of an award, a record that it was won or lost by someone/something. You then define the attributes such as the year, the type of award, its classification etc using taxonomy terms.
To assign it to a movie, set the movie post as the parent post for the
award_won
post. You’ll need to write a metabox to handle this part yourself. To get a list of awards a movie has won, do a post query to find child posts of typeaward_won
.This will let you refer to the winning of individual awards, list all awards of a type, all the awards a movie won, all the people who won a type of award, all the awards allotted in a given year etc etc, and all the data has an associated listing.
You could do the same thing with actors and directors
Alternatively, if you need to track a movie loosing, you could call the post_type
nomination
, and have a taxonomy withlost
andwon
as the terms. You can then set up using pre_get_posts to make sure that unless specified, only nominations in the won term are listed.The only situation this would fail is when an award is given to multiple movies/people at the same time. For example, say an award was given for best onscreen relationship, and the recipient was 2 people, you would have an issue.
So to sum up:
nomination
post typeawards
taxonomyaward_year
taxonomyYou can add additional taxonomies, such as the award type e.g. ‘oscar’ ‘grammy’ ‘golden globe’, and award events ‘MTV Music Awards NYC’, ‘MTV Europe Music Awards Berlin’ etc
Create
award
as a custom post type having the different fields as specified by you.Try using advanced-custom-fields plugin for creating your own custom fields.
You can find the documentation here.
After creating the custom post type you can use posts-to-posts plugin for defining the relations in your posts.
You can go for the documentation here.
Good question because I have also built a movie (also TV show) database that has exactly the same type of meta information as you have described and a few more.
What I did was to create a custom post type named “Awards” but I also created a hierarchical taxonomy called “Award” which can then hold the type of individual award categories associated with the Award Event itself.
I also have a taxonomy for “Year” but its non-hierarchical.
The reason for creating the Award post type was that I wanted to also create specific information for the award event, such as the history of the award so when a visitor clicks on an award, the top of the page has a content box containing a brief history of the event then followed by the awards listed descending order (by year).
I also use the Post 2 Posts plugin to create associations between the posts (actors-to-movies and movies-to-actors etc) however I did not begin my process with this plugin, I added it later in the piece.
Currently there is some duplication data as I also store some of the same information held in the taxonomies mentioned, in post meta fields because initially I was unsure of how I wanted to structure my setup. Its still a work in progress but for now I am satisfied that an,
…is a sufficient way to make these associations between actor, movie and award.