Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. $count=0;
  2. $related = p2p_type($connected_type)->get_related( get_queried_object_id() );
  3.  
  4. // Display related posts
  5. if ( $related->have_posts() ) :
  6. $count++;
  7. while ( $related->have_posts() ) : $related->the_post();
  8. if ($count == 2) {
  9.  
  10. echo the_title();
  11.  
  12. } else {
  13.  
  14. echo 'this post won't show up';
  15. }
  16.  
  17. endwhile;
  18.  
  19. // Prevent weirdness
  20. wp_reset_postdata();
  21.  
  22. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement