I want to build a TV series database using WordPress. I have followed some tutorials and I have two custom post types: one for movies
, one for and series
. I followed this post for the structure.
My question is: how can I make the relationship between the movies and series post types?
Using a Plugin
Some very good plugins for relationships:
Using a Metabox
You can build a simple relationship using metaboxes:
And then, to get the movies relationship as a list for series posts:
I recommend the Posts 2 Posts plugin, which I’ve just started using.
It allows you to create many-to-many relationships between posts and page types, meaning you can link
movies
toseries
, and any other CPTs you may create.This plugin also allows you to create connection metadata which will allow you to get finer detail when creating your connections. It is quite flexible in its usage, allowing for control over admin metaboxes, connection types, and ways to display your connections on the front end. Lastly, it is well-documented.
Unfortunately, the Posts 2 Posts plugin is deprecated and no longer maintained. There is a new alternative plugin for that MB Relationships. It’s inspired by P2P and provides a similar API to create relationships between posts, terms and users.
MB Relationships supports bi-directional relationships by default and use a custom table to store relationships (like P2P) for a better performance (than post meta).
It’s worth taking a look at the plugin.