• Resolved snails07

    (@snails07)


    Not sure if I am on the right track or not but I will explain my problem…

    I have created the connections between video (custom post type) and director (custom post type) and this is working.
    I have a WordPress page template setup that is calling (via WP_Query) a list of videos and the information that goes with each video. This works fine.
    Within this query I am trying to get the name of the connected director using the_title.

    The code I have for the connection is (plus the function and add_action code above and below)

    p2p_register_connection_type( array(
    		'name' => 'director_to_portfolio',
    		'from' => 'director',
    		'to' => 'portfolio',
    		'reciprocal' => true
    	) );

    The code to display the title of the director is this…
    (which is within the WP-Query that is calling the video posts)

    <?php
    // Find connected pages
    $connected = new WP_Query( array(
      'connected_type' => 'director_to_portfolio',
      'nopaging' => true,
    ) );
    
    // Display connected pages
    if ( $connected->have_posts() ) :
    while ( $connected->have_posts() ) : $connected->the_post(); ?>
    	<a>"><?php the_title(); ?></a>
    
    <?php endwhile;
    // Prevent weirdness
    wp_reset_postdata();
    endif;
    ?>

    This is displaying the title of all standard posts. Not sure what I am doing wrong??

    http://wordpress.org/extend/plugins/posts-to-posts/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Posts 2 Posts] Using plugin within another query’ is closed to new replies.