<?php get_header(); ?>

					<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?>
			<div id="content" class="clearfix"><!-- start content -->
			<?php				
							$args = array('post_type'=> 'portfolio', 'order'=> 'DESC', 'orderby' => 'post_date'  );
							$posts = get_posts($args);
							if($posts) {									
								$itemCount=0;
								echo '<ul class="ourHolder">';
								foreach($posts as $post){
									setup_postdata($post); 		
									$match=false;
									$terms =  get_the_terms( $post->ID, 'portfolio_categories' );
				                    $term_list = '';
				                    if( is_array($terms) ) {
				                        foreach( $terms as $currentTerm ) {
				                            if(strcmp($currentTerm->slug, $term->slug) == 0 ){
												$match=true;
												$itemCount++;											
												break;
				                            }
				                        }
				                    }
				                    if($match){
										if($itemCount ==1){
											echo '<h2 style="text-transform:capitalize;">'.$term->slug.'</h2>';
										}
										?>		
										<div class="box-1 fl <?php echo $itemClass; ?>">
											<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
											<div class="hover-caption">
											
												<img src="<?php echo get_template_directory_uri(); ?>/scripts/timthumb.php?src=<?php echo get_image_path($image[0]); ?>&h=129&w=208&zc=1" alt="" />  
												<div class="box">
													<a href="<?php the_permalink();?>" class="info"><strong><?php _e('i','pego_tr'); ?></strong></a>
													
													<?php	
																	$content=get_the_content();
																	if (strlen($content) > (53))
																	{
																		$content=substr($content,0,50).'...';
																	}
																	
																	?>
																	<p><?php echo $content; ?></p>
													
												</div>
											</div>
											<p style="text-align: center; margin-top: 4px;">
												<a href="<?php the_permalink();?>" title="" class="work-title dark-grey-link"><?php the_title(); ?></a><br />
												<div class="work-cat">
													<?php echo get_the_term_list($post->ID, 'portfolio_categories', '', ', ', '');?>
												</div>
											</p>
										</div>  

										<?php
									} //end if match
								 } //end foreach
								echo '</ul>';
							} //end if($posts)
			?>
	
			</div><!-- end content -->	
		</div><!-- end container -->	
<?php get_footer(); ?>
