<?php get_header(); ?>

<?php 
$term = get_term_by('slug', get_query_var( 'term' ), get_query_var( 'taxonomy' )); 

$kk_content_style = get_option('toppic_theme_content_style');
$kk_hp = false;

$kk_parallax = kk_parallax();
$title_type = $kk_parallax[0];
$bg_title_img = $kk_parallax[1];	

?>

   <!-- start content wrapper -->			
	<div class="content clearfix">
		<?php if( $title_type == 'parallax' ) { ?>
			
		<div id="kk-parallax-wrapper" class="kk-parallax-wrapper">
			
			<div id="kk-parallax-bg" class="kk-parallax-bg kk-hidden">
				<img id="kk-img-check" src="<?php echo esc_url( $bg_title_img ) ?>" alt="<?php echo esc_attr( $kk_parallax[2] ) ?>" />
			</div>

			<div id="kk-parallax-title-wrapper" class="kk-parallax-title-wrapper">
				<div id="kk-parallax-title" class="page-title">
					<h1><?php echo esc_html($term->name); ?></h1>
				</div>	
			</div>
			
			<a id="kk-down" class="kk-down is-loading" href="#kk-to-me"></a>
		
		</div>				
		<?php } ?>
		
		<div class="content-inner-wrapper clearfix">
			<span id="kk-to-me"></span>	
		<?php if( $title_type == 'default' ) { ?>
			<div class="page-title">
				<h1><?php echo esc_html($term->name); ?></h1>
			</div>
			
			<div class="divider clear"></div>	
		<?php } ?>
		
			<?php if ( current_theme_supports( 'kk-cpt' ) ) { ?>
			<!-- start portfolio items -->			
			<div class="portfolio-wrapper">
					<ul class="isotope-container" id="three-col-p">
					
						<?php $args = array(
							'post_type' => 'portfolio',
							'posts_per_page' => -1,
							'portfolio-type' => $term->slug
						);
						$query = new WP_Query( $args );

						while ( $query->have_posts() ) : $query->the_post();  ?>
						
						<?php 
								$terms =  get_the_terms( $post->ID, 'portfolio-type' ); 
								$term_list = '';
								
								if( is_array($terms) ) {
									foreach( $terms as $term ) {
										$term_list .= $term->slug;
										$term_list .= ' ';
									}
								}
							?>						
						
							<!-- start work -->
							<li id="<?php echo the_ID()?>" <?php post_class("$term_list isotope-item all"); ?> >
										
								<div class="portfolio-thumb effect-zoom linkto">	
									<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">	
										<?php if( has_post_thumbnail() ): ?>								
											<?php echo get_the_post_thumbnail( get_the_id(), 'kktfwp-s', array( 'class' => 'responsively-lazy-img', 'data-lazy-load' => 1 ) ); ?>
										<?php endif; ?>
										<span class="kk-n"><?php _e('View','toppic'); ?></span>	
									</a>
								</div>
								
								<div class="portfolio-title">
								<h2>
									<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
										<?php the_title(); ?>
									</a>
								</h2>
								</div>	
								<?php if (function_exists('printLikes')) { ?>
									<div class="kk-likes-portfolio">
										<?php printLikes(get_the_ID()); ?>
									</div>
								<?php } ?>	
							</li>
							<?php endwhile; wp_reset_query(); ?>							
							<!-- end work -->
							
							<li id="kk-item-helper"></li>
							<li id="kk-item-helper"></li>
					</ul>
			</div>
			<!-- end latest work -->
			<?php } ?>
		</div>
		
		<?php get_template_part('extends/footer-area') ?>
		
	</div>
	<!-- end content wrapper -->

<?php get_footer(); ?>