<?php
/**
 * Used for the portfolio categories
 * @package Ultra WordPress Theme
 * @since 1.0
 * @author AJ Clarke : http://wpexplorer.com
 * @copyright Copyright (c) 2012, AJ Clarke
 * @link http://wpexplorer.com
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */

get_header(); // Loads the header.php template ?>

<header id="page-heading">
    <div class="boxed clearfix">
        <h1><?php echo single_term_title(); ?></h1>
        <?php
		// Yoast breadcrumbs support
		if( function_exists('yoast_breadcrumb') ) yoast_breadcrumb('<div id="breadcrumbs"><span class="icon-home"></span>','</div>');
		
		// Show a navigation of service items
		if( of_get_option('portfolio_archive_filter','1') == '1' ) {
			$posttype_obj = get_post_type_object( get_post_type( ) );
			$portfolio_terms = get_terms( 'portfolio_category', array(
						'orderby' => 'name',
						'order' => 'ASC',
						'exclude' => of_get_option('portfolio_archive_filter_exclude_ids','')
				) );
				if ( $portfolio_terms ) { ?>
				<ul class="tax-archives-filter clearfix">
					<li class="current"><a href="<?php echo get_post_type_archive_link( $post->post_type ); ?>" title="<?php echo $posttype_obj->label; ?>"><span class="icon-th-large"></span></a></li>
					<?php foreach($portfolio_terms as $portfolio_term) :
						$active_class = ( get_queried_object()->term_id == $portfolio_term->term_id ) ? 'active' : NULL; ?>	
						<li><a href="<?php echo get_term_link($portfolio_term->slug, 'portfolio_category'); ?>" title="<?php echo $portfolio_term->name; ?>" class="<?php echo $active_class; ?>"><?php echo $portfolio_term->name; ?></a></li>
					<?php endforeach; $currentclass = NULL; ?>
				</ul><!-- .tax-archives-filter -->
			<?php }
		} ?>
	</div><!-- .boxed -->
</header><!-- #page-heading -->

<div id="portfolio-category-wrap" class="boxed container clearfix">
	<?php
    // Add post div is sidebar is enabled for these archives
    if( of_get_option('portfolio_archive_sidebar','' ) == '1' ) {
        echo '<div id="post">';
    }
		// Begin Loop
		if( have_posts() ) :
			// Load scripts for masonry style portfolio
			if( of_get_option('portfolio_archive_style' ) == 'masonry' ) {
				wp_enqueue_script('isotope');
				wp_enqueue_script('wpex-isotope-portfolio');
			} ?>
            <div class="portfolio-wrap clearfix">
				<?php
                $wpex_portfolio_count=0;
                while (have_posts()) : the_post();
                    $wpex_portfolio_count++;
                    get_template_part( 'content', 'portfolio' ); // Get portfolio entry layout
                endwhile; ?> 
            </div><!-- #portfolio-wrap -->
            <?php wpex_pagination(); // Paginate your posts
			else :
			_e('There are no posts to show for this archive','wpex');
		endif; // End Loop
	
	// close post div is sidebar is enabled for these archives & get sidebar
    if( of_get_option('portfolio_archive_sidebar','' ) == '1' ) {
        echo '</div>';
        get_sidebar();
    } ?>
</div><!-- #portfolio-archive-wrap -->

<?php get_footer(); //get template footer ?>