I am developing a website for a record label and the basically it uses quite a few custom post types for various pieces of information. My problem is that I feel the same bits of information are being repeated, rather than shared.
I have an artists custom post type, however on the homepage there is a carousel with artists as well but different pieces of information to display. So I have a “homepage carousel” custom post type of which I have to enter the artist names and info, as well as an image and also an “artists” custom post type with some of the same information entered again.
The client is probably not going to like having to enter the same information into multiple custom post types all of the time, is it possible to make a post type inherit from another?
So I can tell my “homepage carousel” post type to inherit from an artists post type so the artist information is shared and doesn’t have to be re-entered again?
At present I have created a custom taxonomy called artists and entered in all possible artist names and then for example in the “homepage carousel” post type I select the artist in the right hand side as being the category. This works well in a way, however you still need to enter a title or you get some “Autosave” nonsense being saved as the title which will make editing and sorting difficult down the track. Is there perhaps a way to set the title as the category “artist” that has been selected?
Let me know if you don’t quite understand and I’ll try and elaborate a bit more. I basically want to share a centralised list of artists and information of which I can inherit from in other post types.
* Update *
A bit more elaboration on my original question.
Here are my defined post types and the information that they hold. What I want to do is set up a shared relationship between my “artists” post type and other post types that relate to the artist in some way.
Post type: artists
Fields: Title, Wysiwyg Editor, Featured Image, Facebook URL, Twitter Username, Website URL.
Post type: homepage_carousel
Fields: Title, Learn More Link, Buy CD Link, Buy MP3 Link
A carousel item corresponds to an artist defined in the artists post type above. So the ability to relate this post type to the artists post type is what I want.
Post type: videos
Fields: Title, Video Embed Code (455px), Video Embed Code (466px), Video Embed Code (608px), Video description.
A video item corresponds to an artist defined in the artists post type. I want to be able to assign a video to an artist.
As you can see I want to basically set up a many-to-one relationship or is it one-to-many relationship? One of those (I think). I’ve started messing with this plugin: http://wordpress.org/extend/plugins/posts-to-posts/ – but I don’t quite understand how to properly use it yet, I think it’s something that I want. So if someone has used this before, your help would be appreciated.
Whilst I am aware of custom taxonomies and terms, I think that what I am wanting goes way beyond the requirements I am seeking as I am dealing with multiple pieces of information and merely want to tie 2 post types together some how.
I have partly solved my own question so-to-speak. I’ve been trying to get post type relationships working for ages and the plugin relation post types as mentioned in my comment to Christopher’s answer. It is far from perfect, but I worked out how to get this plugin: http://wordpress.org/extend/plugins/relation-post-types/ – working (albeit not that pretty).
The following code will fetch a homepage carousel item and then an associated artist name. This can be modified to get related post meta as well. I wanted to use Scribu’s posts 2 posts plugin, but couldn’t work out how to use it.
As you can see this is very hacky and by no means a definitive solution. It worked for me, but I am still unhappy with how the above code works. To get associated post meta it would need more code.
As there is no answer, should this perhaps become a wiki more than a question perhaps? As the solutions listed here will not always be current as WordPress is constantly evolving and new plugins being released.
Hi @Dewayne:
You can’t really “share” a post type; each post has one type.
But I’m more concerned maybe the
'homepage_carousel'
architecture you’ve chose is not right and thus is leading you into all sorts of conundrums like wanting to share post types. Can you describe more in detail what a'homepage_carousel'
holds?At first blush this sounds like a classic case of needing a taxonomy for your
post_type='artist'
called “Featured Locations” (maybe) and you use the tag “Home Page Carousel?”If you can update your question to let me know why that won’t work then I can help you more. Of it if will work then great!
Custom post types and taxonomies are confusing for me too, but I think Mike’s got your answer with his suggestion to use taxonomies here.
The carousel isn’t a type of content you’re wanting to add to the database, it’s content in the database that you want to present. Your answer would then be a query that looks for an artist’s (custom-post-type & taxonomy) albums (custom-post-type) with custom fields (learn more, buy cd, buy mp3), with the ‘featured location’ taxonomy.
Would love to hear other’s thoughts on this as custom post types and taxonomies remain one of the things I find most confusing. In particular I’m not sure how to resolve the artist being both custom post type and taxonomy which I think is necessary in order to allow the extra meta you want as well as the interrelationships with the other data.
In terms of the videos, you may want to look at the post-formats coming up in 3.1 so you wouldn’t need separate embed codes for each size, just a different display attribute.
I hope this is helpful to you or at least furthers the conversation.
Cheers!