Title: [Plugin: Posts 2 Posts] Get connected posts of connected posts
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] Get connected posts of connected posts

 *  Resolved [Aurélien Denis](https://wordpress.org/support/users/maigret/)
 * (@maigret)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-get-connected-posts-of-connected-posts/)
 * Hi,
 * after reading the documentation, I can’t find to solve this problem :
 * “how can I show connected posts of a connected posts of my current post”.
 * Yes, I know it’s a bit strange. Let me explain in more details. I have custom
   post type for Hotel. Golfs are connected to Hotels. And Golfs-Courses are connected
   to Golfs.
 * My goal is to show Golfs-Courses in the loop of my connected Golfs which appeared
   in the Hotel page (single-hotel.php).
 * I tried something like this in the single-hotel.php file : [http://pastebin.com/CzciExmJ](http://pastebin.com/CzciExmJ)
 * If someone could help me, it would be awesome! Thanks.
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-get-connected-posts-of-connected-posts/#post-2690066)
 * Replace this:
 *     ```
       <?php $related = p2p_type( 'golfs_courses' )->get_related( get_queried_object_id() ); ?>
       ```
   
 * with this:
 *     ```
       $related = new WP_Query( array(
         'connected_type' => 'golfs_courses',
         'connected_items' => $post->ID,
         'nopaging' => true,
       ) );
       ```
   
 * And then you have to do something with `$related`. For example:
 *     ```
       while ( $related->have_posts() ) : $related->the_post();
   
       ...
   
       endwhile;
       ```
   
 *  Thread Starter [Aurélien Denis](https://wordpress.org/support/users/maigret/)
 * (@maigret)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-get-connected-posts-of-connected-posts/#post-2690072)
 * Awesome support for an awesome plugin… what else ? 🙂
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-get-connected-posts-of-connected-posts/#post-2690085)
 * I’m not sure what you mean. Were you expecting a free beverage as well? 😛
 *  Thread Starter [Aurélien Denis](https://wordpress.org/support/users/maigret/)
 * (@maigret)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-get-connected-posts-of-connected-posts/#post-2690086)
 * ^^
 * I’ll be happy to offer it you if you come in France – for WordCamp for example.
   😉
 *  Thread Starter [Aurélien Denis](https://wordpress.org/support/users/maigret/)
 * (@maigret)
 * [14 years ago](https://wordpress.org/support/topic/plugin-posts-2-posts-get-connected-posts-of-connected-posts/#post-2690213)
 * Hi Scribu,
 * another question related to the previous lines of code.
 * After the endwhile; I’d like to insert
 *     ```
       <?php comments_template(); ?>
       ```
   
 * But nothing shows… any idea?
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years ago](https://wordpress.org/support/topic/plugin-posts-2-posts-get-connected-posts-of-connected-posts/#post-2690225)
 * I assume you have to call `setup_postdata( $appropriate_post_object );` before
   that.
 * PS: This is getting offtopic.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘[Plugin: Posts 2 Posts] Get connected posts of connected posts’ 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/)

 * 6 replies
 * 2 participants
 * Last reply from: [scribu](https://wordpress.org/support/users/scribu/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/plugin-posts-2-posts-get-connected-posts-of-connected-posts/#post-2690225)
 * Status: resolved