Title: Trouble with loop
Last modified: August 20, 2016

---

# Trouble with loop

 *  Resolved [simisch](https://wordpress.org/support/users/simisch/)
 * (@simisch)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/trouble-with-loop/)
 * Hi,
    I’ve set up a connection type ‘team_to_project’, in the single team view
   the connection works fine. Now I’m trying to run it in the archive page. Same
   code from single view (replacing get_queried_object() by $post) isn’t working.
   Switched to each_connected as written in Wiki. This is my code in the loop:
 *     ```
       p2p_type( 'team_to_project' )->each_connected( $wp_query);
       		foreach ( $post->connected as $post ) : setup_postdata( $post );
       			the_title();
       		endforeach;
       		wp_reset_postdata(); // set $post back to original post
       ```
   
 * Using p2p Version 1.4.3 and murmur theme, running it in archive_team.php
 * I am stuck and appreciate any help.
 * Registration:
 *     ```
       function my_connection_types() {
       	p2p_register_connection_type( array(
       		'name' => 'team_to_project',
       		'from' => 'team',
       		'to' => 'project',
       		'admin_column' => 'any',
       		'admin_box' => 'any',
       		'reciprocal' => true, // the relation has no hierarchy
       		'sortable' => 'any',
       	) );
       }
       add_action( 'init', 'my_connection_types' );
       ```
   
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [simisch](https://wordpress.org/support/users/simisch/)
 * (@simisch)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/trouble-with-loop/#post-3306831)
 * It seems for now it’s the theme functions.php, a function that modifies the loop.
   
   remove:
 *     ```
       if( is_post_type_archive( 'team' ) ) {
       		$query->query_vars['posts_per_page'] = 6;
       		return;
       	}
       ```
   
 * and the connections is displayed

Viewing 1 replies (of 1 total)

The topic ‘Trouble with 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/)

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [p2p](https://wordpress.org/support/topic-tag/p2p/)

 * 1 reply
 * 1 participant
 * Last reply from: [simisch](https://wordpress.org/support/users/simisch/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/trouble-with-loop/#post-3306831)
 * Status: resolved