SHARE
TWEET

Posts 2 Posts 1.4.1 each_connected bug

certainlyakey Aug 24th, 2012 50 Never
  1. <?php
  2.                 $recentPosts = new WP_Query(array('showposts' => 5, 'post_type' => array('artist')));
  3.                 p2p_type( 'posts_to_artists' )->each_connected( $recentPosts );
  4.                         while( $recentPosts->have_posts() ) : $recentPosts->the_post(); ?>
  5. //...
  6. <?
  7.                 // Display connected posts
  8.                 if ($post->connected) {echo '<ul>';}
  9.                 else {echo '<p>This artist has got no connected news items yet</p>';};
  10.                 foreach ( $post->connected as $post ) : setup_postdata( $post );
  11. ?>
  12.                 <li><a href="<? the_permalink(); ?>"><? the_title(); ?></a></li>               
  13. <?              endforeach;
  14.                 if ($post->connected) {echo '</ul>';};
  15.                 wp_reset_postdata(); // set $post back to original post
  16. ?>
RAW Paste Data
Top