Posts 2 Posts within a loop
-
Hi there, I’m running a loop to display classes, using the post type ‘class’ is it possible within this query to then add run the posts 2 posts connected type ‘Class – Teacher’ within this? when I add the following code, it doesn’t output despite there being connections.
<?php query_posts('post_type=class&showposts=-1&orderby=title&order=asc'); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <?php the_title(); ?> <?php $connected = new WP_Query( array( 'connected_type' => 'Class - Teacher', 'connected_items' => get_queried_object(), ) ); if ( $connected->have_posts() ) : ?> ?> <?php while ( $connected->have_posts() ) : $connected->the_post(); ?> <?php the_title(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); endif; ?> <?php endwhile; ?> <?php else : ?> <?php endif; ?>
The basic idea is to list night classes, along with the teachers who will run the class, just not sure where to go from here. Help much appreciated, thanks
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Posts 2 Posts within a loop’ is closed to new replies.