[resolved] [Plugin: Posts 2 Posts] Loop within loop how to access values in field (1 post)

  1. domokun
    Posted 4 years ago #

    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:

    // Find connected pages (for all posts)
    p2p_type( 'posts_to_pages' )->each_connected( $wp_query );
    <?php while ( have_posts() ) : the_post(); ?>
    	<?php the_title(); ?>
    		// 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.

    Like this

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic