[Plugin: Posts 2 Posts] triple nesting, connections of drafts
-
I realized that my previous post was on a resolved message – sorry about that! And this is a rather different question anyway…
I am looping through 3 post types: Timeslot, Session, Speaker, and I want to show all of them, regardless of post status.
I am able to display all of the timeslots (which are all live) and sessions, but when I get to speakers, they only show up on published sessions.Is there a way to show draft speakers that are connected to draft sessions?
Here is a simplified version of my code:
<?php $my_query = new WP_Query( array( 'post_type' => 'timeslot' ) ); p2p_type( 'timeslots_to_sessions' )->each_connected( $my_query, array('post_status' => 'publish, draft'), 'sessions' ); while ( $my_query->have_posts() ) : $my_query->the_post(); ?> <div class="timeslot"> <?php the_title(); ?> <div class="sessions"> <?php p2p_type( 'sessions_to_speakers' )->each_connected( $post->sessions, array('post_status' => 'any'), 'speakers' ); foreach ( $post->sessions as $post ) : setup_postdata( $post ); echo '<div class="sessionrow">'; ?> <div class="sessionbox"> <?php the_title(); ?> <?php the_content(); if(!empty($post->speakers)){ echo '<div class="speakers"><ul>'; foreach ( $post->speakers as $post ) : setup_postdata( $post ); echo("<li>" . get_the_title() ); echo(types_render_field("jobtitle") ? ", " . types_render_field("jobtitle") : ""); echo(types_render_field("company") ? ", " . types_render_field("company") : ""); echo("</li>"); endforeach; echo('</ul> </div>'); } echo "</div>"; endforeach; echo '</div>'; wp_reset_postdata(); ?> </div></div> <?php endwhile; ?>(Note that “types_render_field” is a function provided by the wp-types plugin to display custom fields. That shouldn’t have any effect.)
The topic ‘[Plugin: Posts 2 Posts] triple nesting, connections of drafts’ is closed to new replies.