Title: [Plugin: Posts 2 Posts] Problem with connecting 2 connection types
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] Problem with connecting 2 connection types

 *  [Marco](https://wordpress.org/support/users/mehinger/)
 * (@mehinger)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-problem-with-connecting-2-connection-types/)
 * 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://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

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

 * ![](https://s.w.org/plugins/geopattern-icon/posts-to-posts_7a8e9d.svg)
 * [Posts 2 Posts](https://wordpress.org/plugins/posts-to-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-to-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-to-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-to-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-to-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-to-posts/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Marco](https://wordpress.org/support/users/mehinger/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-problem-with-connecting-2-connection-types/)
 * Status: not resolved