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 am developing a church media center using custom post types.

I have a custom post type called 'Series' and a custom post type called 'Sermons'.

Each Series must have an Title, Image, and Description. Naturally, each Series will be a collection of Sermons (Which will have Audio, Video, and other metadata).

I need to create a Parent/Child relationship with the Series and Sermons. Ideally, when creating a New Sermon entry, I'd like a dropdown list whose options are populated by any available Titles in the post type "Series".

Any suggestions in how to accomplish this?

share|improve this question
    
kind of a duplicate of wordpress.stackexchange.com/questions/7331/… –  Bainternet Jan 21 '11 at 23:06
    
Is this series post type going to actually have posts though? It sounds to me like you actually need a taxonomy for series, in order to group the sermons into series. –  t31os Jan 22 '11 at 14:35
    
Yes, the Series post type will have posts, including content like images, which is why a custom taxonomy will not suffice. I will try the suggestion in the link above and report back! Thanks for the replies... –  user2655 Jan 24 '11 at 18:59
add comment

3 Answers

I've written a couple of posts that can help you in this, I'm still writing the explanation to the final piece of this, but here we go.

First, an explanation on how to set up the post types: this you may not need...

http://drewgourley.com/custom-post-types-for-wordpress/

Second, an explanation on setting up the taxonomies: pay attention to the point here about capabilites!

http://drewgourley.com/extend-post-types-with-custom-taxonomies/

And finally, wrapping it all up: this one's a doosey.

<?php
function associate_posts_register_terms() {
    $args = array('post_type' => '[your type name]', 'numberposts', -1);
    $posts = get_posts($args);
    $lockdown_posts = array();
    foreach ( $posts as $post ) {
        $lockdown_posts[$post->post_name] = $post->post_title;
        if ( get_term_by('slug', $post->post_name, 'post') == false ) {
            $insert = array('slug' => $post->post_name);
            wp_insert_term( $post->post_title, 'post', $insert );
        }
    }
    $posts = get_terms('[your taxonomy name]', array('get' => 'all') );
    foreach ( $posts as $post ) {
        if ( $lockdown_posts[$post->slug] == '') {
            wp_delete_term($post->term_id, 'post');
        } elseif ( $post->name !== $lockdown_posts[$post->slug] ) {
            $update = array('name' => $lockdown_posts[$post->slug], 'slug' => $post->slug);
            wp_update_term($post->term_id, 'post', $update);
        }
    }
}
add_action( 'init', 'associate_posts_register_terms', 2);
?>

After all that is set up appropriately, this function creates taxonomies based on posts which you can use to associate posts back and forth with one another. You'll have to modify it accordingly to suit your needs, of course, but this should get you going. If you need an explanation on how this works exactly, I can supply it, but it should work pretty easily if you just input the correct things into the bracketed areas in the code there.

share|improve this answer
add comment

It sounds like you need a taxonomy. The Organize Series plugin does exactly what you want your series taxonomy to do and includes images. I customized my own post template for within a series to show the series image. Series descriptions can include html and be written rather postlike, as you wish, like so. If you don't want to reinvent the series wheel, you can use the plugin, or just implement its functionality yourself.

share|improve this answer
add comment

Relationships between posts in WP are not currently available natively and are not viewed as feature important enough to be included in core code.

There are plugins available that offer such functionality (such as Posts 2 Posts) and recently there had been initiative started for baseline community-guided plugin.

share|improve this answer
add comment

Your Answer

 
discard

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