<?php  
   $count = 0;
   $inner_count = 0;
   $query_args = array('post_type' => 'bunch_floorplans' , 'showposts' => $num , 'order_by' => $sort , 'order' => $order);
   
   if( $cat ) $query_args['floorplans_category'] = $cat;
   $query = new WP_Query($query_args) ; 
   
   $data_filtration = array();
   $data_content = array();
   ?>
   
<?php if($query->have_posts()):  ?>
<?php while($query->have_posts()): $query->the_post();
	  global $post ; 
	  $floor_meta = _WSH()->get_meta();
	  $active = ($count == 0) ? ' active' : '';
	  $tab_active = ($count == 0) ? '  collapsed' : '';
	  $floor_inner_nav = array();
	  if($floor_plans = tycheproperty_set($floor_meta, 'bunch_floor_features')){
	    foreach($floor_plans as $key => $value){
			$inner_active = ($inner_count == 0) ? ' active' : '';
	  		$inner_tab_active = ($inner_count == 0) ? '  collapsed' : '';
			$floor_inner_nav[$key] = '<li><a class="'.$inner_active.'" href="#'.get_the_id().'-'.$key.'">'.tycheproperty_set($value, 'title').'</a></li>';
			$floor_inner_tab[$key] = '<div class="content-box '.$inner_tab_active.'" id="'.get_the_id().'-'.$key.'">
										  <figure class="image-box"><img src="'.esc_url(tycheproperty_set($value, 'tab_img')).'" alt=""></figure>
									  	  <div class="property-info">
											  <ul class="inline-list">
												  <li><span class="icon flaticon-business-1"></span>'.tycheproperty_set($value, 'area').'</li>
												  <li><span class="icon flaticon-double-king-size-bed"></span>'.tycheproperty_set($value, 'beds').'</li>
												  <li><span class="icon flaticon-old"></span>'.tycheproperty_set($value, 'kitchen').'</li>
												  <li><span class="icon flaticon-buildings-1"></span>'.tycheproperty_set($value, 'bulding').'</li>
											  </ul>
										  </div>
									  </div>';
		$inner_count++;
		}
	  }
	  
	  $data_filtration[get_the_id()] = '<li><a href="#" class="btn-toggle">'.get_the_title($post->ID).'</a>
											<ul class="toggle-nav '.$tab_active.'">
												'.implode("\n",(array)$floor_inner_nav).'
											</ul>
										</li>';
	 $data_content[get_the_id()] = 	implode("\n",(array)$floor_inner_tab);								
	 

?>
<?php $count++; endwhile; endif;
wp_reset_query();
ob_start() ;
?>  

<!--Floor Plans Section-->
<section class="floor-plans-section">
<div class="auto-container">
	
	<!--Section Title-->
	<div class="sec-title">
		<h2><strong><?php echo balanceTags($title);?></strong> <?php echo balanceTags($title1);?></h2>
		<div class="subtitle-text"><?php echo balanceTags($text);?></div>
	</div>
	
	<div class="row clearfix">
		<div class="col-md-2 col-sm-4 col-xs-12">
			<!--Side Links-->
			<nav class="side-links">
				<ul class="links-nav">
					<?php echo implode("\n",(array)$data_filtration);?>
				</ul>
			</nav>
		</div>
		
			
		<div class="col-md-10 col-sm-8 col-xs-12">
			<!--Floors Content-->
			<div class="floors-content">
				<?php echo implode("\n",(array)$data_content);?>	
			</div>
            
        </div>
	</div>
	
</div>
</section>

<?php 
	wp_reset_query();
   $output = ob_get_contents(); 
   ob_end_clean(); 
   return $output ; ?>