Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm very new to WordPress, and from the get-go I need to implement custom post types. Not sure I have all my WordPress marbles in one tin, so I'm asking for a bit of constructive criticism and above all patience.

I want something similar to this: http://wp-types.com/documentation/user-guides/creating-post-type-relationships/. More specifically, the car rental website part, but only customized for events and artists.

BUT, artists will be pre-specified and not added with an event, so I just want to maybe link them via checkbox, is this even possible?

To be specific, this is the scenario:

I have a site, which displays a load of events, each with a line up of artists. Now, I have created two (2) custom post types, Events & Artists. Events is a child of Posts, and Artists a child of Events.

I have already added 'Artist' posts in the post type. Artists should be able to be linked to multiple Events and Events should be able to have multiple Artists.

share|improve this question
    
Close voted: This does not read as a question. Are you asking for how to do the whole implementation? Because that is out of scope of this site I'd say...if you need help with a particular piece, then ask about that particular piece. –  m0r7if3r May 16 '12 at 20:24
1  
Well, my question was if the above parent-child linkage was at all possible between custom post types. This is WordPress forum, and my post is about WordPress, so I don't see how this is out of scope. –  Anriëtte Myburgh May 16 '12 at 21:08

1 Answer 1

up vote 0 down vote accepted

One post type can be the child of another post type: attachments for example are children of posts or pages. The association is described in the posts table in a field post_parent that holds a post ID.

But … what you want can be solved in many different ways. You don't have to use the post_parent field. I don't think that a simple hierarchy can reflect the relations between your objects. You need probably many-to-many relations, and these are not native to WordPress.

  • One blog post or page can cover multiple events, multiple artists or both.
  • One event can be associated with multiple artists and vice versa.

Possible solutions

  • Create a custom taxonomy for artists and build a shadow custom post type for it to hold longer text information and attachments. Not easy to manage, the code gets messy very fast.
  • Save the relationships in post meta data. Then have to decide which data are stored on which post, your queries will get very long and complicated.
  • Use separate tables (one for relationships, one for meta data about these relationships). Requires good knowledge of the WordPress data base API, and you have to take special care to catch these tables in backups and export files.

Maybe the plugin Posts 2 Posts will help you. It uses two extra tables – which is (from my experience with similar situations) the fastest option.

See also this related post about a similar question.

share|improve this answer
    
A while after I posted the question, I thought about giving each event and the artists associated with it a 'event-artist' link in the form of custom taxonomy (event-artist-link), then making that term unique for the event and its artists. Can this work? Is it a valid solution? –  Anriëtte Myburgh May 17 '12 at 7:50
    
BTW. I used Types to create the custom post types & taxonomies, I'm only dabbling with the views. –  Anriëtte Myburgh May 17 '12 at 7:50
    
@AnriëtteCombrink Taxonomies can be used like this, it just is not optimal. Also keep in mind that each data base query for a term-post-relation goes over three tables and may be slow. I have no experience with the Types plugin. –  toscho May 17 '12 at 13:19
    
Will execution time increase as more and more events & artists are loaded? Or will only the amount of links have an effect? –  Anriëtte Myburgh May 17 '12 at 16:08
    
@AnriëtteCombrink Both. Caching will help, but only on the front-end. –  toscho May 17 '12 at 16:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.