<?php
get_header();
	global  $cs_theme_option;
	if(isset($cs_theme_option['cs_layout'])){ $cs_layout = $cs_theme_option['cs_layout']; }else{ $cs_layout = '';} 
	if(isset($cs_theme_option['default_excerpt_length']) && $cs_theme_option['default_excerpt_length'] <> ''){ $default_excerpt_length = $cs_theme_option['default_excerpt_length']; }else{ $default_excerpt_length = '255';}
?>
		
        <div class="<?php cs_default_pages_meta_content_class( $cs_layout ); ?>">
	       	<div class="postlist blog archive-page">
                <!-- Blog Post Start -->
                 <?php 
				 if(is_tax() && get_field('destinatie_desc',get_queried_object()->taxonomy.'_'.get_queried_object()->term_id)){
					echo '<div class="rich_editor_text margin-bottom">';
						echo the_field('destinatie_desc',get_queried_object()->taxonomy.'_'.get_queried_object()->term_id);
					echo '</div>';
					
				}?>
				<?php
                    if (empty($_GET['page_id_all']))
                        $_GET['page_id_all'] = 1;
                    if (!isset($_GET["s"])) {
                        $_GET["s"] = '';
                    }
 					$taxonomy = get_queried_object()->taxonomy;
					$taxonomy_term[] = get_queried_object()->slug;
					
					$args = array( 
					$taxonomy		 => $taxonomy_term,
					'post_type'		 => 'excursii', 
					'paged'			 => $_GET['page_id_all'],
					'post_status'	 => 'publish', 
					'order'			 => 'DESC',
					'tax_query' => array(
						array(
							'taxonomy' => 'status',
							'terms' => array('expirat'),
							'field' => 'slug',
							'operator' => 'NOT IN',
						),
					),
				);
				$custom_query = new WP_Query($args);
                 ?>
                <?php if ( $custom_query->have_posts() ): ?>
                	<div class="row excursii-shortcode">
			            <?php
						    while ( $custom_query->have_posts() ) : $custom_query->the_post();
							$image_url = cs_attachment_image_src(get_post_thumbnail_id($post->ID), 342, 193);
							$post_class = '';
							 if($image_url == ''){
							  $post_class = ' no-image';
							 }
		 					$event_from_date = get_post_meta($post->ID, "cs_event_from_date", true);  
							
								
							?> 
		                    
							<?php include(locate_template('inc/loop-excursii.php')); ?>
								
		                <?php endwhile;  ?>
		            </div>
				
				<?php endif; ?>
                  
        		</div>
                  <?php
                         $qrystr = '';
                        // pagination start
                        	if ($custom_query->found_posts > get_option('posts_per_page')) {
                                      if ( isset($_GET['page_id']) ) $qrystr .= "&page_id=".$_GET['page_id'];
									 if ( isset($_GET['author']) ) $qrystr .= "&author=".$_GET['author'];
									 if ( isset($_GET['tag']) ) $qrystr .= "&tag=".$_GET['tag'];
									 if ( isset($_GET['cat']) ) $qrystr .= "&cat=".$_GET['cat'];
									 if ( isset($_GET['event-category']) ) $qrystr .= "&event-category=".$_GET['event-category'];
									 if ( isset($_GET['cs_cause-category']) ) $qrystr .= "&cs_cause-category=".$_GET['cs_cause-category'];
									 if ( isset($_GET['event-tag']) ) $qrystr .= "&event-tag=".$_GET['event-tag'];
									 if ( isset($_GET['cs_cause-tag']) ) $qrystr .= "&cs_cause-tag=".$_GET['cs_cause-tag'];
									 if ( isset($_GET['m']) ) $qrystr .= "&m=".$_GET['m'];
 						        echo cs_pagination($custom_query->found_posts,get_option('posts_per_page'), $qrystr);
                             }
                        // pagination end
                    
				?>
        </div>  
		<?php
			if ( $cs_layout <> '' and $cs_layout  <> "none" and $cs_layout  == 'right') :  ?>
				<aside class="left-content col-md-3">
					<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($cs_theme_option['cs_sidebar_left']) ) : endif; ?>
				</aside>
		<?php endif; ?>	
<?php get_footer(); ?> 