• Resolved thisissaf

    (@thisissaf)


    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)
Viewing 1 replies (of 1 total)
  • The topic ‘Posts 2 posts 2 posts’ is closed to new replies.