[Plugin: Posts 2 Posts] WP_Query() x get_posts()
-
These values are in database table:
id,from,to
2,2478,3910
3,4075,3910I 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)
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.