• Hey…

    first of all thanks to scribu for such an amazing plugin.

    I am working with wordpress since years. But now I am stuck with a project from one of my clients.

    The client wants to have a database for TV series.

    So I created three post types: Series, Seasons and Episodes.

    My first thought was to make a p2p_register_connection_type seasons <-> series and a p2p_register_connection_type episodes <-> seasons.

    On the single-series.php the conditionals and variables should be ordered like this:

    Example:

    Title of Series: American Horror Story

    American Horror Story tells us the story of Ben and Vivian Harmon an their daughter Violet…

    <hr>

    Seasons

    Season 1
    – Episode 1
    – Episode 2

    Season 2
    – Episode 1
    – Episode 2

    My question is: What can I do to achieve this?

    This is the code I have pasted to my single-series.php:

    // Find connected posts
    $connected = new WP_Query( array(
      'connected_type' => 'season-to-series',
      'connected_items' => get_queried_object(),
      'nopaging' => true,
    ) );
    
    // Display connected posts
    if ( $connected->have_posts() ) :
    ?>
    <h3>Seasons</h3>
    <ul>
    <?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
    	<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>
    
    <?php
    // Prevent weirdness
    wp_reset_postdata();
    
    endif;
    
    ?>
    
    // Find connected posts
    $connected = new WP_Query( array(
      'connected_type' => 'episodes-to-seasons',
      'connected_items' => get_queried_object(),
      'nopaging' => true,
    ) );
    
    // Display connected posts
    if ( $connected->have_posts() ) :
    ?>
    <h3>Episodes</h3>
    <ul>
    <?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
    	<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>
    
    <?php
    // Prevent weirdness
    wp_reset_postdata();
    
    endif;
    
    ?>

    I am thankful for every hint. The project is done if I can solve this problem!

    Thanks for reading this!

    http://ww.wp.xz.cn/extend/plugins/posts-to-posts/

The topic ‘[Plugin: Posts 2 Posts] Problem with connecting 2 connection types’ is closed to new replies.