Say I have a custom post type called “Performers”. This gets populated with different bands/performers. These posts have a featured image as well as custom fields (mp3 file, facebook link, myspace link, etc).
I have another custom post type called “Events”.
When I create a new Event post, I would like the option to have a drop box to select one of the bands from the “Performers” custom post type.
This will insert all data from the specific Band/Performer into the Event post (custom fields, featured image, etc.).
What is the best method for inserting/injecting this sort of loop from the “Event” admin?
Currently the best way I know to handle that is the Posts 2 Posts plugin:
Here’s an example showing how to set up the custom post types (if you already have them it’s more for other’s benefit who might be reading this) as well as the function call to
p2p_register_connection_type()
needed by the plugin to set up the post relationships. This can can go in your theme’sfunctions.php
file or in a.PHP
file for a plugin you might be writing:Then within your theme’s template file
single-event.php
you can add code like the following to display information about each Band (I showed the basics here; I’ll leave for you to fill in all the details and/or to ask other more specific questions here on the WordPress Answers site such as if you need to know how to get the featured image, etc.)