Posts 2 posts 2 posts
-
Hi There,
I have 2 post types on my website:
– artists
– artworks
– productI 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 productsI 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
- The topic ‘Posts 2 posts 2 posts’ is closed to new replies.