  <?php get_template_part('header');?>
  <body <?php body_class();?>>
 	<?php get_template_part('topbar');?>
    <?php get_template_part('logoarea');?>
    <?php 
	 $cat = get_query_var('cat');
  	$thiscat = get_category ($cat);
  	 if(function_exists("get_field") && get_field("sticky_posts_section", $thiscat)){
    get_template_part("stickyposts"); 
	}?>
    <div class="wrapper" id="maincontent">
    	<div class="container">
   <?php 
	if ( have_posts() ) {?>
    <div class="content-heading">
    			<h2><?php single_cat_title(); ?></h2>
                <small><?php echo esc_html(strip_tags(category_description())); ?></small>
                <span class="divider"></span>
            </div>
            <div class="relative">
		<div class="row nonfeaturedposts isotopefilter" data-id="archivecontent">
		<?php while ( have_posts() ) {the_post();  ?>
        			<?php 
					$category = "";
					if(isset($featured_ids) && is_array($featured_ids) && in_array($post->ID,$featured_ids) && get_field("hide_featured", $thiscat)) continue;
					if(function_exists("get_field") && get_field("filter_by", $thiscat) == "categories"){
					$category = get_the_category();
					}elseif(function_exists("get_field") && get_field("filter_by", $thiscat) == "tags"){
                    $category = get_the_tags();
					}
					?>
					<div class="col-sm-3 col-xs-6<?php if(is_array($category)){ foreach($category as $cat){ echo esc_html(" ".$cat->slug); $catarray[$cat->slug] = $cat->name; }}?>">
                	<div <?php post_class("post"); ?>>
                		<a href="<?php the_permalink(); ?>"><?php the_title();?></a>
                        <h3><?php the_title();?></h3>
                        <small><?php _e( 'Author: ', 'activehost');?><?php the_author();?></small> 
                        <small><?php _e( 'Category: ', 'activehost');?><?php
						$i = 0;
						$categories = get_the_category();
						foreach($categories as $cat){$i++;
							if($i!=1){
								echo esc_html(", ".$cat->cat_name);
							}else{
								echo esc_html($cat->cat_name);
							}
						}
						?></small>
    
                        <div class="post-image"><?php the_post_thumbnail(); ?><span><i class="glyphicon glyphicon-calendar"></i><?php the_time('jS M'); ?></span></div>
                         <?php the_excerpt(); ?>
                     </div>
                </div>
		<?php } // end while ?>
		</div>
        <?php paginate_links();?>
        <?php if(function_exists("get_field") && get_field("filter_by", $thiscat) && get_field("filter_by", $thiscat) != "none"){?>
        <div class="suboptions" data-holder="archivecontent">
						<div class="btn-group">
						  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
							<?php _e( 'View All', 'activehost');?> <span class="caret"></span>
						  </button>
						  <ul class="dropdown-menu" role="menu">
							<li><a href="#all" data-filter="*"><?php _e( 'View All', 'activehost');?></a></li>
                            <?php $catarray = array_unique($catarray); 
                            foreach($catarray as $catslug => $catname){?>
                            <li><a href="#<?php echo esc_html($catslug); ?>" data-filter=".<?php echo esc_html($catslug); ?>"><?php echo esc_html($catname); ?></a></li>
                            <?php }?>
                          </ul>
                          </div>
                          </div>
     <?php }?>			
   </div>
	<?php } // end if ?>
    
    	</div>
    </div>
 <?php get_template_part('footer');?>