Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $my_query = new WP_Query( array(
- 'post_type' => 'recipes'
- ) );
- p2p_type( 'recipes_to_tips' )->each_connected( $my_query, array(), 'tips' );
- p2p_type( 'recipes_to_chefs' )->each_connected( $my_query, array(), 'chefs' );
- ?>
- <?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
- <p>The Recipe</>
- <?php the_title(); ?>
- <?php
- // Display connected tip
- echo '<p>Tip:</p>';
- foreach ( $post->tips as $post ) : setup_postdata( $post );
- the_title();
- endforeach;
- wp_reset_postdata();
- // Display connected chef
- echo '<p>Chef:</p>';
- foreach ( $post->chefs as $post ) : setup_postdata( $post );
- the_title();
- endforeach;
- wp_reset_postdata();
- ?>
- <?php endwhile; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement