<?php
$count_all=0;
if (!isset($portfolio_cat_slug)) $portfolio_cat_slug="";
if (!isset($portfolio_cat_ID)) $portfolio_cat_ID="";

$countquery = array(
	'post_type' => 'mtheme_portfolio',
	'types' => $portfolio_cat_slug,
	'orderby' => 'menu_order',
	'order' => 'ASC',
	'posts_per_page' => -1,
	);
query_posts($countquery);
if (have_posts()) : while (have_posts()) : the_post();
$count_all++;
endwhile;endif;
?>
<div class="filter-heading-description">
<?php echo $count_all . " "; if ($count_all==1) { _e('Item','mthemelocal'); } else { _e('Items','mthemelocal'); } ?>
</div>
<div>
<h2 id="filter-heading">
	<?php _e('All items','mthemelocal'); ?>
</h2>
</div>


	<ul class="portfolio-filter clearfix">
	
	<li class="filter-tag-icon">Tag
	</li>
		
	<li class="current all">
		<a data-title="<?php echo $count_all . " "; if ($count_all==1) { _e('Item','mthemelocal'); } else { _e('Items','mthemelocal'); } ; ?>" href="#">
		<?php _e('All items','mthemelocal'); ?>
		</a>
	</li>
	
	<?php					
	$categories=  get_categories('child_of='.$portfolio_cat_ID.'&orderby=slug&taxonomy=types&title_li=');
	foreach ($categories as $category){
		
		$taxonomy = "types"; // can be category, post_tag, or custom taxonomy name

		// Use any one of the three methods below

		// Using Term ID
		//$term_id = $category->term_id;
		//$term = get_term_by('id', $term_id, $taxonomy);

		// Using Term Name
		//$term_name = 'A Category';
		//$term = get_term_by('name', $term_name, $taxonomy);

		// Using Term Slug
		$term_slug = $category->slug;
		$term = get_term_by('slug', $term_slug, $taxonomy);

		// Fetch the count
		//echo $term->count;
	?>
	<li class="<?php echo "filter-" . $category->slug;?>">
		<a data-title="<?php echo $term->count  . " "; if ($term->count==1) { _e('Item','mthemelocal'); } else { _e('Items','mthemelocal'); } ;?>" href="#">
			<?php echo $category->name;?>
		</a>
	</li>
	<?php }?>
	</ul>
