WordPress.org

Support

Support » How-To and Troubleshooting » Custom post types and relations

Custom post types and relations

  • s it possible to create a relation between a custom post type and a regular post?

    Let’s say that my post is about a movie that I have defined as a custom post type. How do i make such a relation in WP 3.0?

Viewing 15 replies - 1 through 15 (of 27 total)
  • Related it in what sense? In this case would wonder why you even need a custom post type.

    I have several authors that write reviews about movies. There can be several reviews (posts) about a movie. I would like to make the movie as a custom post type. Each movie should have a title, description and a EAN-number.

    When looking at a movie I would like to link to all the reviews (posts) of that movie.
    When looking at a review (post) I would like to link to the movieinformation-page.

    Is this possible in WordPress 3.0? And how would I go about it to make it work?

    My only problem is how to create a relation between custom posts.

    I’ve actually found two plugins for this:

    http://wordpress.org/extend/plugins/custom-post-relationships/
    I’ve tried this plugin, and defined the relation between a movie and a post. But I’m not sure how to edit the template, so that there is links from a movie to the posts and from the posts to the movie.

    http://wordpress.org/extend/plugins/custom-post-relationships/
    This plugin can only (when writing this) only create relations between posts. It seems as it will be updated in the future to also be able to handle custom posts.

    I’m having a problem with this plugin using the widget, it outputs unrelated data.

    Is there another way to output related data?

    I also have a plugin that supports connections between all post types (including attachments):

    http://wordpress.org/extend/plugins/posts-to-posts/

    probablepossible

    @probablepossible

    scribu, I just installed your plugin– but i cannot find a meta box in edit-post, or a link in the TOC or anything!

    You need to register a connection type. An example is right on the plugin page.

    probablepossible

    @probablepossible

    Ah– via the plugins editor, huh?
    Okay– I have a very limited knowledge of php coding. I can copy and paste your example and I know what to change for my purposes. But in which file do I put it? You don’t say, and I’ve looked though your files and I am not experienced enough to know by their contents.

    Ah, sorry about that. Just put in your theme’s functions.php file.

    stevebluck

    @stevebluck

    You could create a custom write panel with a dropdown box with all movies listed inside it. This way you could create a relation between the two and have them do whatever.

    You will need someone with coding knowledge though.

    Hey Scribu! Thanks for your amazing plugin!

    I got to make the connection, but I have no idea how to query it…
    Exemple: I have two related post types called “review” and “movie”. I created the relationship between both. ok.

    Now I want a query like: On the Movie page, I want to show all reviews related to that movie. What should I do?

    Thanks!!!!

    Since you’re on 04-beta, you can do this:

    global $post;
    
    query_posts( array(
      'post_type' => 'review',
      'connected' => $post->ID,
    ) );
    probablepossible

    @probablepossible

    Scribu, would that effectively become a table of contents?

    If the post type is arranged hierachally, would the list be in the ordered format?

    Scribu, would that effectively become a table of contents?

    No, you still have to write the loop to display the found posts.

    If the post type is arranged hierachally, would the list be in the ordered format?

    Don’t know. See the Codex:

    http://codex.wordpress.org/Function_Reference/query_posts#Orderby_Parameters

Viewing 15 replies - 1 through 15 (of 27 total)
  • The topic ‘Custom post types and relations’ is closed to new replies.