<div id="single" class="ad-gallery">
<div class="ad-image-wrapper">
</div>
<div id="description"></div>
<div class="ad-controls">
</div>
<div class="ad-nav">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php $category = get_the_category($post->ID); ?>
<?php $termlist = wp_get_post_terms( $_POST['id'], 'clients', array("fields" => "all")); ?>
<?php $client = get_terms('clients', 'orderby=count&hide_empty=0'); ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full'); ?>
<?php $image_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail'); ?>
<div class="ad-thumbs">
<ul class="ad-thumb-list">
<li>
<a href="<?php echo $image[0]; ?>">
<img src="<?php echo $image_thumb[0]; ?>" title="<?php echo the_title(); ?>" data-ad-desc="<?php echo the_content(); ?>">
</a>
</li>
<?php endwhile;
endif;
?>
<?php
global $post;
$terms = get_the_terms( $_POST['id'] , 'clients');
$do_not_duplicate[] = $_POST['id'];
if(!empty($terms)){
foreach ($terms as $term) {
query_posts( array(
'clients' => $term->slug,
'posts_per_page' => -1,
'caller_get_posts' => 1,
'post__not_in' => $do_not_duplicate ) );
if(have_posts()){
while ( have_posts() ) : the_post(); $do_not_duplicate[] = $post->ID; ?>
<?php print_r($post);exit(); ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full'); ?>
<?php $image_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail'); ?>
<a href="<?php echo $image[0]; ?>">
<img src="<?php echo $image_thumb[0]; ?>" title="<?php echo the_title(); ?>" data-ad-desc="<?php echo the_content(); ?>">
</a>
<?php endwhile; wp_reset_query();
}
}
}
?>
</ul>
</div>
</div>
</div>