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 have a Roster page which contains two sections. The first section contains the artist with their pictures, short bios, and website links; and the second section contains the combined videos of every artist in the roster.

Similar to this:

roster

Normally, I'd create two separate post types; one for 'artist' and another for 'artist videos' but I was wondering if there was a way I can somehow combine the two? So in the admin panel, it would look something like this:

admin

If possible, how would I go about doing this? Or am I over-thinking this (as I often do) and is there an easier way?

share|improve this question
    
When I look at that screenshot, I see three models: videos, artists (a person), and bands (a group of artists, possibly only one). In that case, you could create a custom post type "Artist" for a person, a post type "Video", and a taxonomy "Band" that can be attached to artists and videos. You could also create an extra custom post type "Band info" where you store extra information about the band. But the idea to introduce a taxonomy would be the crucial part here (also interesting if you have a video that features more than one band). –  Jan Fabry Feb 21 '11 at 13:10

2 Answers 2

It would take some custom coding, but there is a way to keep both custom post types and link the artist and video post types together. It involves using the post_parent property of a post to make them hierarchical without combining the two.

I'm currently using the following code to attach one post type to another:

function parent_select ($parent_type) {
    global $post;
    global $wpdb;
    $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = '{$parent_type}' AND post_status = 'publish' ORDER BY post_title";
    $results = $wpdb->get_results($query, OBJECT);
    echo '<select name="parent_id" id="parent_id">';
    echo '<option value = "">None</option>';
    foreach ($results as $r) {
        echo '<option value="', $r->ID, '"', $r->ID == $post->post_parent ? ' selected="selected"' : '', '>', $r->post_title, '</option>';
    }
    echo '</select>';
}

Add this to a metabox on your video edit pages, passing your artist type as the parent type. It'll create a dropdown box that will list all the artists you have. Just select one and update and that video now sees the artist you selected as a parent. After that, you can create a custom template to pull all the videos for any particular artist.

share|improve this answer

Don't quite know if i get you right, but you could make one hierarchical post type and then diversify either by level in the hierarchy or by some meta value you add.

Edit: To rephrase, you simply create an 'ArtistOrVideo' post type, so to speak, and make it hierarchical. It represents both. The first level (post_parent=0) you always treat as an Artist. The second level (post_parent points to a post with post_parent = 0) you always treat as a video. You can then react in your metabox-callback to that as well and create the Artist metabox for post_parent=0 posts and the video metabox for the others. I'm pretty sure you can take this through the whole application.

However, the canonical alternative at hand is: Can't you create an 'Artists' Taxonomy instead?

share|improve this answer
    
The part that's troubling me is the fact that each artist in the roster has an unspecified amount of videos. I can create an 'Artists' post type and a separate 'Artist Videos' post type and this way I'd be able to easily create an unlimited amount of 'artist video' posts with a custom meta box for the video url. But if I just create one post type for 'Artists', it will only have one custom meta box for the video url for each new post and I don't know how I'd add more if that artist comes out with a new video. –  J82 Feb 21 '11 at 1:39
    
See edit above, you didn't quite get me. ;-) –  wyrfel Feb 21 '11 at 12:07

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.