<?php
// Template Name: Portfolio 2 Column
/**
 *
 * @package progression
 * @since progression 1.0
 */

get_header(); ?>

<?php get_template_part( 'child-page', 'navigation' ); ?>

<?php while(have_posts()): the_post(); ?>
	<?php the_content(); ?>
	<div class="clearfix"></div>
<?php endwhile; ?>


<div id="portfolio-post-container">
<?php
$port_number_posts = of_get_option('portfolio_page_posts',6);
$portfolio_type = get_the_term_list( $post->ID, 'portfolio_type' );
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$portfolioloop = new WP_Query(array(
	'posts_per_page' => $port_number_posts,
    'paged'          => $paged,
    'post_type'      => 'portfolio',
    'tax_query'      => array(
        // Note: tax_query expects an array of arrays!
        array(
            'taxonomy' => 'portfolio_type', // my guess
            'field'    => 'name',
            'terms'    => $portfolio_type
        )
    ),
));

$count = 1;
$count_2 = 1;

?>

<?php if ( have_posts() ) : while ( $portfolioloop->have_posts() ) : $portfolioloop->the_post();
if($count >= 3) { $count = 1; }
 ?>
	
	<div class="grid2column <?php if($count == 2): echo ' lastcolumn'; endif; ?>">
		<?php get_template_part( 'content', 'portfolio' ); ?>
	</div>

<?php if($count == 2): ?><div class="clearfix"></div><?php endif; ?>

<?php $count ++; $count_2++; endwhile; ?>
<div class="clearfix"></div>
</div><!-- close #portfolio-post-container -->

<div class="clearfix"></div>
<?php kriesi_pagination($portfolioloop->max_num_pages, $range = 2); ?>

<?php endif; ?>

<?php if(of_get_option('page_comments_default', '0')): ?><?php comments_template( '', true ); ?><?php endif; ?>

<?php get_footer(); ?>