Im using “each_connected()” to get the connected pages for all posts once.
(As seen in the Looping the Loop tutorial: https://github.com/scribu/wp-posts-to-posts/wiki/Looping-The-Loop)
So my code looks something like:
<?php // Find connected pages (for all posts) p2p_type( 'posts_to_pages' )->each_connected( $wp_query ); ?> <?php while ( have_posts() ) : the_post(); ?> <?php the_title(); ?> <?php // Display connected pages echo '<p>Related pages:</p>'; p2p_list_posts( $post->connected ); ?> <?php endwhile; ?>
The above works just fine.
What Id like to do right below “related pages” is to output a meta field called date.
echo p2p_get_meta( $post->connected, 'date', true ).', ';
Yet when I do that, the same meta field gets echo’d for all posts. I.e. it doesn’t look as though the queried object is being updated.
- The topic ‘[Plugin: Posts 2 Posts] Loop within loop how to access values in field’ is closed to new replies.