<?php get_header(); 
        
    wp_reset_postdata();
		
	$sidebar_position = get_field('sidebar_position','options'); 
	$col_md_pull = "";  
	$col_md_push = "";
	$container_class = "col-md-8"; 

	if ( is_active_sidebar( 'sidebar-main' ) ){		
		if($sidebar_position == 'left'){
			$col_md_push = "col-md-push-4";
			$col_md_pull = "col-md-pull-8";
		} 
	}
	else{
		$container_class = "col-md-12";
	}
		
	$featuredImageType = get_field('background_image_type','options'); 
	setBgImg(true);
?>



<main class="content blog2Page <?php echo $featuredImageType; ?>">
	
		<section class="pageImage">
			
			<?php if($featuredImageType == "bgImg"): ?>	
				<div class="fullBg"></div>
			<?php elseif($featuredImageType == "headerImg"): ?>
				<div class="um_parallax" data-velocity="-.1"></div>
			<?php endif; ?>
        
        </section>
	
        <div class="container">
        	
        	<section class="pageTitle text-center">
                    <div class="um_helper">
                    	<div class="um_middle">
                    		<?php if(is_search()): ?>
                    			<h3 class="title pageTitle titleUp"><?php _e("Search",'um_lang'); ?></h3>
                    		<?php else: ?>
                    			<h3 class="title pageTitle titleUp"><?php _e("Archive",'um_lang'); ?></h3>
                    		<?php endif;  ?>
                    	</div>
                    </div>
                </section>
            
            <div class="row">
	            <div class="<?php echo $container_class.' '.$col_md_push; ?>">
		            <section class="blogItems">
						

						 <?php  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
                        <?php while ($wp_query->have_posts()):
                            $wp_query->the_post(); 
								
										$post_categories  = get_the_category();
										$post_categories_names = '';
										$post_categories_realNames = '';
										if($post_categories){
											foreach ($post_categories as $post_cat){
												$post_categories_names .= str_replace(' ', '_',$post_cat->name)." ";
												$post_categories_realNames .= $post_cat->name.', ';
											}
											$post_categories_realNames = substr($post_categories_realNames, 0, -2);
										}
										$classes = array(
											 'blogItem',
											 'animated',
											 'um_in',
											 'mainBgColor'
										);
							?>
						
						
						
						
						<a href="<?php the_permalink(); ?>">
							<article id="post-<?php the_ID(); ?>" <?php post_class($classes); ?> >
								<div class="row">
									<header class="col-md-6">
										<div class="headerContainer">
													<?php the_post_thumbnail('blogMasonry', array('class' => 'img-responsive')); ?>
											</div>
										</header>
									<div class="itemContainer col-md-6">
										<h5 class="category"><?php echo $post_categories_realNames; ?></h5>
										<h5 class="title titleUp"><?php the_title(); ?></h5>
										<div class="itemContent">
											<?php echo excerpt(35); ?>
										</div>
									</div>
								</div>
							</article>
						</a>	
						
						<?php endwhile; ?>	
					</section>
					<?php if($wp_query->max_num_pages != 1){
						 pagination($wp_query,$wp_rewrite); 
					} ?>
				</div>
				<?php if ( is_active_sidebar( 'sidebar-main' ) ):?>
					
					
					<div class="col-md-4 <?php echo $col_md_pull; ?> ">
						<aside class="sidebar">
							<?php dynamic_sidebar( 'sidebar-main' );?>
						</aside>
					</div>
				<?php endif; ?>
			</div><!-- row-->
        </div>
    </main>



<?php get_footer(); ?>