Skip to content

Instantly share code, notes, and snippets.

@jrstaatsiii
Created December 11, 2011 18:24
Show Gist options
  • Save jrstaatsiii/1461932 to your computer and use it in GitHub Desktop.
Save jrstaatsiii/1461932 to your computer and use it in GitHub Desktop.
Attempt at Post 2 Post
<h2>Technology</h2>
<ul>
<?php
//Target The Client CPT & Taxonomy
$technology_args = array(
'post_type' => 'client',
'order_by' => 'title',
'order' => 'ASC',
'posts_per_page'=> '-1',
'tax_query' => array(
array(
'taxonomy' => 'industry-type',
'field' => 'slug',
'terms' => 'technology'
)
)
);
//Setup The Query
$technology_query = new WP_Query( $technology_args );
//Check to see if there is a relationship between a client and a case study
p2p_type( 'clients_to_case_studies' )->each_connected( $technology_query );
//The Loop
while( $technology_query->have_posts() ) : $technology_query->the_post();
?>
<?php if( !empty( $post->connected ) ) { ?>
<li>
<?php the_title(); ?>
<?php p2p_list_posts( $post->connected ); ?>
</li>
<?php } else { ?>
<li>
<?php the_title(); ?>
<p>not connected</p>
</li>
<?php } ?>
<?php endwhile; wp_reset_query(); ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment