Title: resetting posts while nested
Last modified: August 20, 2016

---

# resetting posts while nested

 *  Resolved [econofast](https://wordpress.org/support/users/econofast/)
 * (@econofast)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/resetting-posts-while-nested/)
 * Apologies if this is covered somewhere, but I can’t seem to find it.
 * How do you “go up a level” when nesting more than once? In my case, I set up 
   the wp_query called “my_query” (for “timeslots”), then use an each_connected 
   to attach connections (for “sessions”). Inside of that loop, I use another each_connected
   to attach “speakers” to the sessions.
 * Here’s the short version:
 *     ```
       $my_query = new WP_Query( array(my options) );
       p2p_type( 'timeslots_to_sessions' )->each_connected( $my_query, array(), 'sessions' );
       while ( $my_query->have_posts() ) : $my_query->the_post();
       foreach ( $post->sessions as $post ) : setup_postdata( $post );
         ... show session info ...
         p2p_type( 'sessions_to_speakers' )->each_connected( $post->sessions, array(), 'speakers' );
         foreach ( $post->speakers as $post ) : setup_postdata( $post );
           ... show speaker info ...
         endforeach;
         ... here I'd like to show more session info ...
       endforeach;
       endwhile;
       ```
   
 * How do I reset the post info so it points back to the sessions data in the original“
   foreach” loop?
 * I hope that makes sense. I can send along real code if that helps!
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [econofast](https://wordpress.org/support/users/econofast/)
 * (@econofast)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/resetting-posts-while-nested/#post-3402642)
 * I figured it out – you _have_ answered it already!
 * [http://wordpress.org/support/topic/plugin-posts-2-posts-cant-display-connected-posts-am-i-doing-this-correct?replies=12#post-2737727](http://wordpress.org/support/topic/plugin-posts-2-posts-cant-display-connected-posts-am-i-doing-this-correct?replies=12#post-2737727)

Viewing 1 replies (of 1 total)

The topic ‘resetting posts while nested’ 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: [econofast](https://wordpress.org/support/users/econofast/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/resetting-posts-while-nested/#post-3402642)
 * Status: resolved