Title: [Plugin: Posts 2 Posts] WP_Query() x get_posts()
Last modified: August 19, 2016

---

# [Plugin: Posts 2 Posts] WP_Query() x get_posts()

 *  Resolved [pavelevap](https://wordpress.org/support/users/pavelevap/)
 * (@pavelevap)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-wp_query-x-get_posts/)
 * These values are in database table:
 * id,from,to
    2,2478,3910 3,4075,3910
 * I tried to connect posts to pages, so there are two posts (2478 and 4075) connected
   to page 3910.
 * Then I wanted to list connected posts to my page:
 *     ```
       $sc_query = new WP_Query( array(
         'suppress_filters' => false,
         'post_type' => 'post',
         'connected_to' => $post->ID) );
   
       if($sc_query->have_posts()) :
   
       echo '<ul>';
   
       while($sc_query->have_posts()):$sc_query->the_post(); ?>
       <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
   
       <?php
       endwhile;
       echo '</ul>';
       endif;
       wp_reset_query();
       ```
   
 * $post->ID is correct 3910, but there are both connected posts with many others?
   I do not understand why, because in p2p table are only these 2 rows?
 * And when I use get_posts(), everything works well:
 *     ```
       $connected = get_posts( array(
         'suppress_filters' => false,
         'post_type' => 'post',
         'connected_to' => $post->ID,
       ) );
   
       echo '<ul>';
   
       foreach( $connected as $post ) : setup_postdata($post); ?>
       <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
       <?php endforeach;
   
       echo '</ul>';
       ```
   
 * I am out of ideas… Same query, different results?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [pavelevap](https://wordpress.org/support/users/pavelevap/)
 * (@pavelevap)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-wp_query-x-get_posts/#post-1893385)
 * Oh, probably my mistake, not related to Posts 2 Posts plugin, but interesting…
 * Problem was related to parametr caller_get_posts which was false by default, 
   but I had there many sticky post and so they were passed automatically into WP_Query()…
 * Adding `'caller_get_posts' => true` solved my troubles…
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-wp_query-x-get_posts/#post-1893393)
 * Yeah, makes sense, since get_posts() automatically sets some parameters.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Posts 2 Posts] WP_Query() x get_posts()’ 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/)

 * 2 replies
 * 2 participants
 * Last reply from: [scribu](https://wordpress.org/support/users/scribu/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-wp_query-x-get_posts/#post-1893393)
 * Status: resolved