0

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?

3
  • kind of a duplicate of wordpress.stackexchange.com/questions/7331/…
    – Bainternet
    Commented Jan 21, 2011 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
    Commented Jan 22, 2011 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
    Commented Jan 24, 2011 at 18:59

3 Answers 3

1

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.

1

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.