<?php // Fetch the Portfolio Categories
global $post;
$term =  wp_get_post_terms( $post->ID, "portfolio-category" );
$parentpage = get_template_link("portfolio.php");
$cat_list = get_terms("portfolio-category", "orderby=count&hide_empty=0");
?>
<?php get_header(); ?>
	<?php $post_type = get_post_type( $post ); ?>
	<?php if ( is_single() &&  $post_type == 'portfolio' ) : ?>
	<h2 class="section-title"><?php echo $parentpage->post_title; ?> <span>/ <?php if(is_array($term)): ?> <a href="<?php echo get_term_link($term[0]->slug, "portfolio-category"); ?>"> <?php echo $term[0]->name; ?></a> / <?php endif; ?> <?php the_title(); ?></span></h2>

		<?php if (have_posts()) :
            global $post;
            while (have_posts()) : the_post(); setup_postdata($post);
				get_template_part("/functions/fetch-portfolio");
            endwhile;
        else :
            ocmx_no_posts();
        endif; ?> 

	<?php get_footer(); ?>
   	<?php else : ?>
   	<div id="left-column">
		<?php if (have_posts()) :
            global $post;
            while (have_posts()) : the_post(); setup_postdata($post);
				get_template_part("/functions/fetch-post");
            endwhile;
        else :
            ocmx_no_posts();
        endif; ?> 
        	
    	<?php comments_template(); ?>
	</div>
	<?php get_sidebar(); ?>
<?php get_footer(); ?>
  <?php endif; ?>
   	