<?php
/**
 * The template for displaying all single posts.
 *
 * @package Maskitto Light
 */

get_header();
$catnow = get_the_category(get_query_var('p'));
?>


<?php if( isset( $catnow ) && $catnow['0']->term_id && $catnow['0']->term_id > 0 ) { ?>
	<div class="page-category">
		<div class="container">
			<a href="<?php echo get_permalink( get_option( 'page_for_posts' ) ); ?>" class="category-item<?php if( !get_query_var('cat') ) { echo ' active'; } ?>"><?php _e( 'All', 'maskitto-light' ); ?></a>
			<?php

			$args = array(
				'type'                     => 'post',
				'child_of'                 => 0,
				'parent'                   => '',
				'orderby'                  => 'count',
				'order'                    => 'desc',
				'hide_empty'               => 1,
				'hierarchical'             => 1,
				'exclude'                  => '',
				'include'                  => '',
				'number'                   => '',
				'taxonomy'                 => 'category',
				'pad_counts'               => false 

			);
			$categories = get_categories( $args );
			foreach ($categories as $category) { ?>
				<?php if( isset( $catnow['0'] ) && $category->cat_ID == $catnow['0']->cat_ID ) { ?>
					<a href="<?php echo get_category_link( $category->term_id ); ?>" class="category-item active-category"><?php echo $category->cat_name; ?></a>
				<?php } else { ?>
					<a href="<?php echo get_category_link( $category->term_id ); ?>" class="category-item"><?php echo $category->cat_name; ?></a>
				<?php } ?>
			<?php } ?>
			<?php if( count( $categories ) > 6 ) { ?>
				<a href="#" class="category-item category-show-all"><?php _e( '(more)', 'maskitto-light' ); ?></a>
			<?php } ?>
		</div>
	</div>
<?php } ?>

<div class="page-section page-blog">
	<div class="container">
		<div class="blog-post">

			<?php while ( have_posts() ) : the_post(); ?>

				<?php get_template_part( 'content', 'single' ); ?>

				<?php maskitto_light_post_nav(); ?>

				<div class="blog-bottom-large">
					<?php
						// If comments are open or we have at least one comment, load up the comment template
						if ( comments_open() || get_comments_number() ) :
							comments_template();
						endif;

						if ( is_singular() ){
							wp_enqueue_script( 'comment-reply' );
						}
					?>
				</div>

			<?php endwhile; ?>

		</div>
	</div>
</div>

<?php get_footer(); ?>
