Title: [Plugin: Posts 2 Posts] $connected not working in loop
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] $connected not working in loop

 *  Resolved [Matt Sartori](https://wordpress.org/support/users/msartori/)
 * (@msartori)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-connected-not-working-in-loop/)
 * Hi,
 * This code is returning data just fine:
 *     ```
       $connected = new WP_Query( array(
         'connected_type' => 'projects_to_projects',
         'connected_items' => get_queried_object(),
         'nopaging' => true
       ) );
       ```
   
 * When I try to loop and print the results, nothing is echoed to the screen. The
   following code does not seem to print anything.
 *     ```
       // Display connected pages
       if ( $connected->have_posts() ) {
   
       	echo '<ul class="group">';
       		while ( $connected->have_posts() ) : $connected->the_post();
       			echo '<h3 class="project-title">' . $post->post_title . '</h3>';
       		endwhile;
       	echo '</ul>';
   
       	// Prevent weirdness
       	wp_reset_postdata();
   
       }
       ```
   
 * ( if ( $connected->have_posts() ) ) looks like it returns false so nothing happens
   inside of that if/then. Could it be a problem that $connected is returning an
   object with yet another object inside that contains the actual post data?
 * [Here’s a pastebin link to the code I’m using.](http://pastebin.com/E0aTdrk1)
 * [This is the actual output from the site.](http://sportg.tunedev.com/projects/test-project-1/)
 * Thanks!
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Matt Sartori](https://wordpress.org/support/users/msartori/)
 * (@msartori)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-connected-not-working-in-loop/#post-3073338)
 * Just for posterity’s sake I wanted to say there’s nothing wrong with the plugin
   or the code I posted. I just misunderstood how reciprocal connections work.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Posts 2 Posts] $connected not working in loop’ is closed to 
new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/posts-to-posts_7a8e9d.svg)
 * [Posts 2 Posts](https://wordpress.org/plugins/posts-to-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-to-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-to-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-to-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-to-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-to-posts/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Matt Sartori](https://wordpress.org/support/users/msartori/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-connected-not-working-in-loop/#post-3073338)
 * Status: resolved