[Plugin: Posts 2 Posts] How to call two post types connected in one query?
-
First, this plugin is fantastic! Second, the problem. In my project there are two post types connected:
post
andwriters
. At home there are nested loops with last 10 posts, each post with its writer. But I wonder if there are too many queries to DB.`while (have_posts()) : the_post();
the_title();$the_query = new WP_Query( array(
‘post_type’ => ‘writer’,
‘connected’ => $post->ID, ) );
while ($the_query->have_posts()) : $the_query->the_post();
the_title();
endwhile;endwhile;`
Is it posible to create only one WP_Query object with last 10 posts with its writers connected for only one loop?
I hope I make myself clear. Thanks!
- The topic ‘[Plugin: Posts 2 Posts] How to call two post types connected in one query?’ is closed to new replies.