Title: Posts 2 posts 2 posts
Last modified: November 11, 2016

---

# Posts 2 posts 2 posts

 *  Resolved [thisissaf](https://wordpress.org/support/users/thisissaf/)
 * (@thisissaf)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/posts-2-posts-2-posts/)
 * Hi There,
 * I have 2 post types on my website:
    – artists – artworks – product
 * I would like to connect all three so that on the artist single page I can show
   –
   Al its related artworks, and within each arwork: – Al its related products
 * I am currently using these connections in functions.php:
 * ****************************
    function my_connection_types() { p2p_register_connection_type(
   array( ‘name’ => ‘artisttoartwork’, ‘from’ => ‘artist’, ‘to’ => ‘artwork’ ) );
 *  p2p_register_connection_type( array(
    ‘name’ => ‘artworktoproduct’, ‘from’ =
   > ‘artwork’, ‘to’ => ‘product’ ) );
 *  p2p_register_connection_type( array(
    ‘name’ => ‘artisttoproduct’, ‘from’ =>‘
   artist’, ‘to’ => ‘product’ ) );
 * }
    add_action( ‘p2p_init’, ‘my_connection_types’ );
 * ****************************
 * And use this code to show all artworks of the artist:
 * ****************************
    <?php // Find connected pages $connected = new 
   WP_Query( array( ‘connected_type’ => ‘artisttoartwork’, ‘connected_items’ => 
   get_queried_object(), ‘nopaging’ => true, ) ); …… ?> ****************************
 * How can I create a loop within this loop to show each product for each artwork?
 * Thanks!!
 * Stijn

Viewing 1 replies (of 1 total)

 *  [Elliot Taylor](https://wordpress.org/support/users/raisonon/)
 * (@raisonon)
 * [9 years ago](https://wordpress.org/support/topic/posts-2-posts-2-posts/#post-9146501)
 * +1
 * Looking for ability to filter by multiple connecting item types

Viewing 1 replies (of 1 total)

The topic ‘Posts 2 posts 2 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/)

 * 1 reply
 * 2 participants
 * Last reply from: [Elliot Taylor](https://wordpress.org/support/users/raisonon/)
 * Last activity: [9 years ago](https://wordpress.org/support/topic/posts-2-posts-2-posts/#post-9146501)
 * Status: resolved