scribu/wp-posts-to-posts — pull request #348 by scribu (2013-06-12 13:35:24+00:00)
Title: Replace each_connected() with something less confusing

`each_connected()` is confusing because it doesn't return anything; instead, it produces side-effects on the $wp_query object.

It would be better if it returned something which the user could explicitly manipulate.

Proposed syntax:

```php
$connected_locations = p2p_type( 'posts_to_locations' )->connected_many( $wp_query );
$connected_pages = p2p_type( 'pages_to_posts' )->connected_many( $wp_query );

while ( have_posts() ) : the_post();

foreach ( $connected_locations->for( $post ) as $post ) : setup_postdata( $post );
the_title();
endforeach;
wp_reset_postdata();

foreach ( $connected_pages->for( $post ) as $post ) : setup_postdata( $post );
the_title();
endforeach;
wp_reset_postdata();

endwhile;
```

cc: @markjaquith, @aaroncampbell

### History

Initially, all the querying was done through WP_Query query vars (including 'each_connected').

Then, the idea of explicit connection types came along and the query vars were replaced with `P2P_Connection_Type->get_connected()`.

Then, the preference went back to query vars (#61).