Title: [Plugin: Posts 2 Posts] Display Connect Projects on Single Client Page
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] Display Connect Projects on Single Client Page

 *  Resolved [jrstaatsiii](https://wordpress.org/support/users/jrstaatsiii/)
 * (@jrstaatsiii)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-display-connect-projects-on-single-client-page/)
 * Hey Scribu – I’m trying to display a list of projects connected to a client, 
   on that particular client’s page. Both are setup as custom post types, and I 
   am using single-client.php to handle this.
 * In functions.php I have this:
 *     ```
       //Setup Posts 2 Posts Connectivity
       	function portfolio_to_client_connection() {
       		// Make sure the Posts 2 Posts plugin is active.
       		if ( !function_exists( 'p2p_register_connection_type' ) )
       			return;
   
       		p2p_register_connection_type( array(
       			'name' => 'client_to_portfolio',
       			'from' => 'client',
       			'to' => 'portfolio',
       			'reciprocal' => true
       		) );
       	}
       	add_action( 'wp_loaded', 'portfolio_to_client_connection' );
       ```
   
 * And in single-client.php I have this:
 *     ```
       <div class="appended-portfolio wrap">
   
       <?php
       	// Find connected pages
       	$connected = new WP_Query($args);
   
       	$args =  array(
       	  'connected_type' => 'client_to_portfolio',
       	  'connected_items' => get_queried_object(),
       	  'nopaging' => true
       	);		
   
       ?>
   
       <?php if ( $connected->have_posts() ) : while ( $connected->have_posts() ) : $connected->the_post(); ?>
   
       <div class="portfolio-item">
       	<div class="portfolio-thumbnail">
       		<?php if ( function_exists( 'get_the_image' ) ) { ?>
       			<?php get_the_image( array( 'order_of_image' => 1, 'size' => 'anthem_portfolio', 'the_post_thumbnail' => false)); ?>
       		<?php } else { ?>
       		<?php if ( has_post_thumbnail() ) { ?>
       			<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('anthem_portfolio'); ?></a>
       		<?php } } ?>
       	</div>
       	<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
       </div>
       <!-- end .portfolio-item -->
   
       <?php endwhile; else: ?>
       	<p><?php _e('Sorry, there are no projects matched to this client.'); ?></p>
       <?php endif; ?>
   
       </div>
       <!-- end .appended-portfolio -->
       ```
   
 * When I fire up a client page that has projects connected it displays the default“
   Sorry there are no projects matched to this client” message.
 * I was hoping a second set of eyes would help me through this. Thanks again for
   the hard work on this plugin.
 * Rich
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

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

 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-display-connect-projects-on-single-client-page/#post-2996475)
 * You’re defining `$args` _after_ creating `WP_Query`.
 *  Thread Starter [jrstaatsiii](https://wordpress.org/support/users/jrstaatsiii/)
 * (@jrstaatsiii)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-display-connect-projects-on-single-client-page/#post-2996484)
 * oh my god. i am an idiot. LOL, i knew I needed a second set of eyes. Thanks scribu!

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

The topic ‘[Plugin: Posts 2 Posts] Display Connect Projects on Single Client Page’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/posts-to-posts_7a8e9d.svg)
 * [Posts 2 Posts](https://wordpress.org/plugins/posts-to-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-to-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-to-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-to-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-to-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-to-posts/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [jrstaatsiii](https://wordpress.org/support/users/jrstaatsiii/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-display-connect-projects-on-single-client-page/#post-2996484)
 * Status: resolved