• Resolved econofast

    (@econofast)


    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/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘resetting posts while nested’ is closed to new replies.