<?php 
$args = array( 'post_type' => 'bunch_projects', 'showposts'=>$num, 'orderby'=>$sort, 'order'=>$order );
$terms_array = explode(",",$exclude_cats);
if( $exclude_cats ) $args['tax_query'] = array( array( 'taxonomy' => 'projects_category','field' => 'id','terms' => $terms_array,'operator' => 'NOT IN' ) );
$query = new WP_Query($args);

$t = $GLOBALS['_bunch_base'];

?>

<?php 
if( $query->have_posts() ):
ob_start();
$fliteration = array();
?>
	<?php while( $query->have_posts() ): $query->the_post();
		global  $post;
		$projects_meta = _WSH()->get_meta();
		$post_terms = get_the_terms( get_the_id(), 'projects_category');// printr($post_terms); exit();
		foreach( (array)$post_terms as $pos_term ) $fliteration[$pos_term->term_id] = $pos_term;
		$temp_category = get_the_term_list(get_the_id(), 'projects_category', '', ', ');
	?>
		<?php $post_terms = wp_get_post_terms( get_the_id(), 'projects_category'); 
		$term_slug = '';
		if( $post_terms ) foreach( $post_terms as $p_term ) $term_slug .= $p_term->slug.' ';?>		
		<?php 
			$post_thumbnail_id = get_post_thumbnail_id($post->ID);
			$post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id );
        ?>
        <?php $term_list = wp_get_post_terms( get_the_id(), 'projects_category', array( "fields" => "names" ) ); ?>
        <div class="gallery-item-three mix all <?php echo esc_attr( $term_slug ); ?>">
        
			<div class="inner-box">
				<div class="image">
					<?php the_post_thumbnail( 'buildark_384x340', array( 'class' => 'img-responsive' ) );  ?>
					<div class="overlay-box">
						<div class="option-box">
							<a href="<?php echo esc_url( buildark_set( $projects_meta, 'ext_url' ) );  ?>" class="image-link"><span class="icon fa fa-link"></span></a>
							<a href="<?php echo esc_url( $post_thumbnail_url );  ?>" class="lightbox-image image-link"  data-fancybox-group="example-gallery" title="<?php esc_attr_e('image', 'buildark');?>"><span class="icon fa fa-search-plus"></span></a>
						</div>
						<div class="content">
							<h3><a href="<?php echo esc_url( buildark_set( $projects_meta, 'ext_url' ) );  ?>"><?php the_title(); ?></a></h3>
							<div class="category"><?php echo implode( ', ', (array)$term_list );?></div>
						</div>
					</div> <!-- /.text -->
				</div> <!-- /.single-project -->
			</div> <!-- /.col- -->
			
		</div>
<?php endwhile;?>

<?php wp_reset_postdata();
$data_posts = ob_get_contents();
ob_end_clean();

endif ;
ob_start();?>

<?php $terms = get_terms( array( 'projects_category' ) ); ?>

<section class="project-section  fullwidth-galley">
    <div class="auto-container">
        <div class="sec-title centered light">
            <h2><?php echo wp_kses_post( $title ); ?></h2>
        </div> <!-- /.theme-title -->
    </div> <!-- /.container -->

	<div class="mixitup-gallery">

	   <div class="filters clearfix">
			<ul class="filter-tabs filter-btns">
				<li class="filter active"  data-role="button" data-filter="all"><?php esc_attr_e( 'BUILDINGS', 'buildark' ); ?></li>
				<?php foreach( $fliteration as $t ): ?>
				<li class="filter"  data-role="button" data-filter=".<?php echo esc_attr( buildark_set( $t, 'slug' ) ); ?>"><?php echo wp_kses_post( buildark_set( $t, 'name' ) ); ?></li>
				<?php endforeach;?>

			</ul>
		</div> <!-- End of .mixitUp-menu -->

		<div class="filter-list clearfix">

			<?php echo wp_kses_post( $data_posts ); ?>

		</div> <!-- /.row -->

	</div>
</section> <!-- /.our-project -->